-
What's the best way to implement optional section headings (much like Markdown's) like
where there aren't super-explicit closing delimiters? I see from #153 that one way to do it is to use Thanks very much in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @ym-han, sorry for the late response. You can use a parser rule like this to identify the end of section headings: Section: 'SECTION' content=TEXT (EOL+ | EOF); // EOF is a builtin keyword that matches the end of a file
terminal EOL: /\r?\n/;
terminal TEXT: [^\n\r]+; A general word of warning: Markdown like languages are very difficult to parse using LL based parsers (like Langium). Parsers for those languages are usually handwritten due to very specific behavior wrt to stuff like line endings, ambiguity detection and error recovery. It can work, but it's often a lot more effort than necessary. |
Beta Was this translation helpful? Give feedback.
Hey @ym-han,
sorry for the late response. You can use a parser rule like this to identify the end of section headings:
A general word of warning: Markdown like languages are very difficult to parse using LL based parsers (like Langium). Parsers for those languages are usually handwritten due to very specific behavior wrt to stuff like line endings, ambiguity detection and error recovery. It can work, but it's often a lot more effort than necessary.