I’m excited to share my implementation of a Language Server powered by Lezer. This project showcases the potential of Lezer for creating sophisticated language features, demonstrating its capabilities beyond traditional syntax highlighting.
The Ungrammar Language Features includes a VS Code extension, a Language Server, and an Online Playground, all built on top of the powerful Lezer parser. By leveraging Lezer, we’ve been able to effectively parse Ungrammar code, convert it from Concrete Syntax Trees (CSTs) to Abstract Syntax Trees (ASTs), and provide a range of intelligent language features.
While this project is relatively simple, it serves as a valuable example of how Lezer can be applied to create custom language support for various programming languages. I encourage you to explore the project and learn more about the possibilities that Lezer offers.
Interesting approach. I guess if you have a Lezer grammar already, the code that converts from a Lezer tree to an actual AST might be less complicated than writing a full traditional parser. Is the lack of useful parse error messages not something that causes problems?
While implementing the Ungrammar LSP ecosystem, I encountered challenges in effectively detecting errors within the Lezer CST. Although the parser could identify unexpected syntax errors, it often lacked specific information regarding missing elements.
To address this limitation, I introduced a strategy of treating certain invalid nodes as valid within the Lezer grammar. By analyzing the generated AST from the Ungrammar language, I could more accurately detect invalid nodes and provide more informative error messages.
Additionally, I explored the potential of leveraging the Ungrammar language itself to detect missing nodes within the AST. While this approach was not fully implemented, it demonstrated promise and could be further explored in future iterations of the project.
Choosing Lezer as the parser for my LSP ecosystem was a strategic decision driven by its incremental parsing and error recovery capabilities. These features significantly reduce the development effort required to create a robust and efficient parser, allowing me to focus on other critical aspects of the LSP implementation.