jreyesr / jreyesr.github.io

jreyesr's personal blog, detailing all sorts of explorations into assorted development topics
https://blog.jreyesr.com
3 stars 0 forks source link

posts/langium/ #10

Open utterances-bot opened 2 weeks ago

utterances-bot commented 2 weeks ago

Langium and language engineering - jreyesr's blog

In this article we review Langium, which is a language engineering tool that can be used when developing custom structured text languages. It can generate parsers for them, and provides useful services such as validation, code generation, syntax highlighting, autocompletion, a LSP server, web-only support, and the ability to generate VS Code extensions for the language.

https://jreyesr.github.io/posts/langium/

msujew commented 2 weeks ago

Hey, I just came across your blog post. Great stuff, thank you for the in-depth review!

I just wanted to give some input on the scannerless parsing: You're definitely right that Langium has trouble dealing with non-traditional languages that were created using scannerless parsers. Usually, one can work around that by modifying the lexer service, (in the worst case running a pre-scan that simulates PEG parsing), but that's a bit of work.

The main reason we shied away from PEG parsers is that they're incredibly slow - at least when compared to Chevrotain. We deal with pretty large workspaces a lot of the times (i.e. 100k+ LoC) and using common PEG parsing libraries would make Langium basically unusable for those use cases. Also, most of them don't support error recovery which is a must-have for using the parser in a language server.

FYI, I mostly fixed your GH query language grammar (couldn't get sort to work, due to a grammar ambiguity) here.