New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ebnf parser #3574
Add ebnf parser #3574
Conversation
I moved the parser to a separate repo, as it seems installation from monorepos is not supported. |
It's supported. See vlang or tsx/typescript |
queries/ebnf/highlights.scm
Outdated
@@ -0,0 +1,47 @@ | |||
;;;; Simple tokens ;;;; | |||
(terminal) @string @grammar.terminal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI fails because @grammar
is a undocumented new highlight type, There are a few possibilities to fix this:
- Is
@grammar
needed for other languages? Then@grammar
or better@grammar.punctuation
should be documented inCONTRIBUTING.md
and added to all languages where necessary - Is
@grammar
similar to a existing highlight group inCONTRIBUTING.md
? Then, it should be changed to@XXX.grammar.nonterminal
whereXXXX
is a documented capture. This way users will have a good default experience when their color scheme does not support@grammar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I called it @grammar
and not @ebnf
because there are other notations besides EBNF to express context-free grammars and they all have terminals and non-terminals, but instead of adding a new top-level @grammar
I will now change them like this:
@grammar.terminal
->@string.grammar
@grammar.special
->@string.special.grammar
@grammar.nonterminal
->@variable.grammar
Let me know what you think of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be ok. But I think your old @grammar
categories were also ok, since they can be surely extended to other languages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @grammar
captures could also be used for ANTLR/Yacc/Bison/JFlex/CUP/etc. but none of them have TS grammars (that I know of) yet and I think existing captures can adequately describe all their tokens anyway.
Highlights can currently be customised with @string.ebnf
and so on without needing a custom suffix.
Alright, thanks for the info, will move it back into the monorepo then |
Your EBNF files read nicely. Have you tried generating |
Ooops, closed by mistake. New PR: #3860 |
The parser is part of this repo under crates/tree-sitter-ebnf