Skip to content

End grammar rules using EOL? #1510

Answered by msujew
PatrikN-work asked this question in Q&A
May 23, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hey @PatrikN-work,

I've adjusted your language to work as expected with regards to EOL markers. See this playground link. You can see what kind of AST the input produces by toggling the syntax tree viewer.

Note that I would generally recommend against employing newline-delimited languages, as they don't behave very well when it comes to error recovery behavior in Langium. Unless you're reimplementing an existing language in Langium, you're almost always better suited using a different delimiter like ;. Generic parsers are generally pretty bad at handling unexpected input in whitespace-aware languages. It also makes maintenance on the grammar pretty difficult, as you always need to keep tr…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@PatrikN-work
Comment options

@msujew
Comment options

Answer selected by PatrikN-work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants