Place island grammars into separate files #4442
Unanswered
renatahodovan
asked this question in
Q&A
Replies: 1 comment 1 reply
-
IIRC the imports need to come first i.e.:
Your example seems to lean more towards an include. That's not supported. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
It's might be a dummy question, but is it possible to organize island grammars into separate files and import them into the main grammar (or is it something equivalent solution to avoid copy-pasting island rules into the main grammar)?
E.g., If I'd like to parse an HTML file with style definitions and scripts:
HTMLParser.g4
HTMLLexer.g4
Where CSSLexer.g4 and CSSParser.g4 contain the CSS rules and JavaScriptLexer.g4 and JavaScriptParser.g4 contain the JS rules. (The snippet above is obviously wrong, since ANTLR is complaining about the lexer imports.)
Beta Was this translation helpful? Give feedback.
All reactions