UserNobody14 / tree-sitter-dart

Attempt to make a tree-sitter grammar for dart
MIT License
56 stars 33 forks source link

Consider generating the grammar.js from the official language spec #36

Open TzviPM opened 1 year ago

TzviPM commented 1 year ago

Would you be open to a contribution that generates the grammar.js from the .tex file of the official specification in the dart/language repo?

TimWhiting commented 1 year ago

I think that would be great if it works well. I can help review. However note that this might be difficult since the tree sitter grammar is a different sort of grammar.

TzviPM commented 1 year ago

I think that would be great if it works well. I can help review. However note that this might be difficult since the tree sitter grammar is a different sort of grammar.

That makes sense. The main thing we could run into is the deep nesting discussed at https://tree-sitter.github.io/tree-sitter/creating-parsers#structuring-rules-well. I think this can be avoided by having rules that solely exist as choices between non-terminal simply not appear in the AST.

TimWhiting commented 1 year ago

I like the idea, right now I'm working on making the grammar conform more closely to the Antler spec that is checked into the dart sdk repo. After that, we can figure out whether we still want to migrate to a generator. The main problem with be figuring out the rule conflicts to insert.