Skip to content

Tree-sitter: ambiguous grammar, Makefile, unicode, and comments #556

Open

Description

@Commelina

@katrinafyi Some information that may be helpful for you (found by bnfc-system-tests):

  1. For ambiguous grammar like
        entrypoints Exp ;
    
        EPlus. Exp ::= Exp "+" Exp;
        EInt.  Exp ::= Integer;
    
    Currently bnfc --tree-sitter will finish normally, but tree-sitter generate will fail:
        Unresolved conflict for symbol sequence:
    
          Exp  '+'  Exp  •  '+'  …
    
        Possible interpretations:
    
          1:  (Exp  Exp  '+'  Exp)  •  '+'  …
          2:  Exp  '+'  (Exp  Exp  •  '+'  Exp)
    
        Possible resolutions:
    
          1:  Specify a left or right associativity in `Exp`
          2:  Add a conflict for these rules: `Exp`
    
    Many other tools like happy and bison will choose one of them (maybe with a warning), but I am not sure what the best practice should be for tree-sitter.
  2. Currently the generated Makefile is placed under tree-sitter-xxx/, while for most of other backends (including --latex) it is directly placed at current directory. Should we align it with other backends, or is this a special design?
  3. Unicode: test testing/regression-tests/249_unicode failed.
  4. Comments: test testing/regression-tests/202_comments failed.

Activity

  1. added
    tree-sitter
    on Mar 25, 2026
  2. Commelina commented on Mar 26, 2026

    @Commelina
    MemberAuthor

    @katrinafyi For the first one, maybe it is fine to keep it unchanged (with some extra info in docs?)? It could be quite complicated to add such checks (also, making decisions implicitly can be confusing sometimes?). But it is up to you to choose the best behavior :)

  3. katrinafyi commented on Mar 27, 2026

    @katrinafyi
    Contributor

    Yeah, I'm just not sure what the best way would be. In my own use of the tree-sitter backend, I've just resolved the ambiguities in the source .cf file and I think this is good because it ensures consistent behaviour across backends, rather than trying to match the implicit behaviour of other backends. So, I'm leaning towards leaving it as-is but, yes, some info in docs would be good. I'll write that eventually.. :)

  4. added this to the 2.9.7 milestone on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tree-sitter

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions