how to match EOF #1048
-
Is it possible to match end of file (EOF)? I tried using:
But it didn't work out for me. Originally, I wanted to create a language in which newlines were important. For example, an assignment statement:
If I used:
It well make the following code valid:
So now I've got to add a newline after that assignment statement to make sure that each statement is on a separate line, but if the assignment was at the EOF, it creates an exception asking for a newline (playground). |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 22 replies
-
I think EOF matching can be accomplished with Langium but is rather complicated. Instead I would recommend the following approach:
And remove |
Beta Was this translation helpful? Give feedback.
-
After #1162 has been merged, how to actually use it as a rule instead of a value? I'm trying to create a fragment rule so that could have either |
Beta Was this translation helpful? Give feedback.
-
Another issue came across: The issue only occurred when trying to run the language server; it's generates AST correctly without any issue. Test cases that are run in node (vitest) are passing. But any grammar that has pattern regex that matches everything break the language server, e.g., here is /([^\n\r:]+?(?=%%)|[^\n\r:]+)/ EDIT: the pattern is overridden in |
Beta Was this translation helpful? Give feedback.
Am I missing something?
Added a dummy terminal rule:
Override
TokenBuilder
: