Rule Order - If none of the above criteria can be used to select one token over another, Tree-sitter will prefer the token that appears earlier in the grammar.
In this case, the conflict is between /[^@:\s\$]+/ and /[aA][sS]/. We want to identify AS as a keyword following the image name rather than as a fragment of the image name.
Unfortunately, we run into this issue because ocaml-tree-sitter transforms a grammar in a few ways, which results in some anonymous rules being factored out and given a name. This changes the relative placement of the patterns that match tokens (e.g. /[^@:\s\$]+/ and /[aA][sS]/), causing incorrect parsing as shown above.
I'm not sure what the best solution should be. I'm looking into it.
Correct output with the current grammar:
Incorrect output if we place the
image_name
rule before thefrom_instruction
rule:This is due to fallback rule 5 in case of conflicting tokens which specifies:
In this case, the conflict is between
/[^@:\s\$]+/
and/[aA][sS]/
. We want to identifyAS
as a keyword following the image name rather than as a fragment of the image name.Unfortunately, we run into this issue because ocaml-tree-sitter transforms a grammar in a few ways, which results in some anonymous rules being factored out and given a name. This changes the relative placement of the patterns that match tokens (e.g.
/[^@:\s\$]+/
and/[aA][sS]/
), causing incorrect parsing as shown above.I'm not sure what the best solution should be. I'm looking into it.