Does Langium a good fit for a Svelte-like language? #859
-
Hello, I need to implement a syntax that looks like that:
I just learned about Langium. I think it would be possible to use recursive rules, create My question: Is Langium suitable for creating a language with syntax similar to Svelte / HTML, and are there any examples available? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hey @arthur-fontaine, thanks for your question! I've updated your playground to work as expected, see here. The There was also another issue related to ambiguous grammar rules, but that is easily fixed. Anyway, HTML should be fairly straightforward to build. Note that Langium is best suited for languages with static typing. I see a lot of Also, if you're looking for a more in-depth example on how to build an expression language, take a look at the langium-lox repo. |
Beta Was this translation helpful? Give feedback.
Hey @arthur-fontaine, thanks for your question!
I've updated your playground to work as expected, see here. The
TEXT
terminal messes with a lot of stuff in Langium, due to it being effectively being a catch-all terminal. We perform a few heuristics to optimize lexing/parsing performance, including reordering of token types. In this case it gets moved in front of all other tokens due to it's ability to match a whitespace character, which prevents everything else from being lexed. So in a real langium project you might need to fine-tune the token generation.There was also another issue related to ambiguous grammar rules, but that is easily fixed.
Anyway, HTML should be fairly straightforwa…