Understanding Tree-sitter error "Unresolved conflict for symbol sequence"


#1

In an error like this:

Error: Unresolved conflict for symbol sequence:

  '{'  identifier  •  '{'  …

Possible interpretations:

  1:  '{'  (plg_def  identifier)  •  '{'  …
  2:  '{'  (plg_def  identifier  •  plg_hash)

Possible resolutions:

  1:  Specify a left or right associativity in `plg_def`
  2:  Add a conflict for these rules: `plg_def`

The corresponding rule is:

plg_def: $ => seq(
  $.identifier,
  optional(choice(
    seq(optional($.plg_value), $.plg_hash),
    $.plg_value,
    $.plg_function
  ))
),

My questions:

  • What does the stand for?
  • How would the possible resolutions look like?
    • A assume 1 suggests using prec.left() or prec.right(). Where would I put those and why?
    • Is there any documentation concerning conflicts? It seems like the chapter on this has not been written yet.

#2

I might have been a little too quick with posting. apparently marks the spot where the ambiguity arises, and does not stand for some token. So I could fix this by wrapping the rule in prec.right():

plg_def: $ => prec.right(seq(
  $.identifier,
  optional(choice(
    seq(optional($.plg_value), $.plg_hash),
    $.plg_value,
    $.plg_function
  ))
)),

Could one paraphrase that right associativity makes the rule “greedy” in the regular expression sense?