Announcing Langium 0.3
After months of work, we are finally able to announce the release of Langium 0.3. It features extensive changes to our grammar infrastructure, so let’s dive right in:
Multi-language support
After adding workspace support in Langium 0.2, we now also support working with multiple languages within a single language server. Each language gets its own dedicated grammar and file extension. This change comes hand in hand with the added support to import other grammars, which allows you to cross-reference elements from other languages.
Due to the extend of this change, we had to break a large amount of existing APIs. If you are wondering how to migrate from Langium 0.2, consult the changelog or ask us directly.
Explicit type declarations
Until now, types in Langium have been inferred from the grammar rules. While this is a very powerful feature for small DSLs, it can be a source of breaking changes for mature language projects since every grammar change potentially also changes the generated types. To resolve this problem we now support explicit type declarations. Using a TypeScript like syntax, types can now be declared directly in the grammar. These types will be directly added to the generated meta-model:
interface Entity {
name: string
visibility?: "public" | "private" | "protected" // '?' indicates an optional property
superType?: @Entity // '@' indicates a reference type
features: Feature[]
}
type Symbol = Entity | PackageDeclaration | DataType | Feature
These type declarations will help you to avoid accidentally introducing breaking changes. They can also be mixed with existing, inferred types.
This feature introduces a breaking change in the grammar language:
Before, parser rules used the returns
directive to infer a new type.
We now differentiate between two cases and use an infers
keyword when a new type has to be inferred, and a returns
keyword when a declared type is referenced.
New quick fixes and validations will help you navigate these changes.
Other noteable changes
- We finally have a website to host guides, tutorials and documentation for Langium.
- The new langium-sprotty package introduces Eclipse-Sprotty support. You can see it in action here.
- Importing other grammar files by simply using
import './path/to/grammar'
. - Support rule guard conditions.
If you’re interested in everything that happened during the last months, you can take a look at our changelog.
What’s next?
Now that we’ve performed a bulk of grammar changes, we aim to keep future releases a bit smaller. Expect to see more regular releases from now on!
- More language server features, such as formatting and improved completion
- Better utilities for testing your languages
Stay tuned for more updates on Langium by watching the repository over at GitHub. Also, if you’re interested in contributing to Langium, consider joining TypeFox. We’re hiring!
About the Authors
Mark Sujew
Mark is the driving force behind a lot of TypeFox’s open-source engagement. He leads the development of Langium and is a very active member of the Theia IDE development team. Away from his day job, he enjoys bartending and music, is an avid Dungeons & Dragons player, and works as a computer science lecturer at a Hamburg University.
Irina Artemeva
Irina is deeply passionate about programming language and compiler theory. In her efforts to put theory into practice, she promotes LLVM within TypeFox and spearheads projects aimed at DSL compilation using Langium and LLVM. Outside of the digital realm, she enjoys playing guitar, climbing, and making origami.
Read more about this topic
Mar 18th 2024
Irina Artemeva
Run fast, debug easy: Exploring the synergy of Langium and LLVM
Ensuring your language is both executable and debuggable is an interesting challenge. Let's discover how to achieve this using Langium and LLVM.
read the articleMar 7th 2024
Benjamin F. Wilson
Getting started with Langium – Part 7 "Generating Drawing Commands"
In this tutorial Ben will demonstrate how we can generate drawing commands from a MiniLogo program, building on the generator work we’ve already established in the prior tutorial.
watch the videoMar 5th 2024
Benjamin F. Wilson
Langium 3.0 is Released!
Langium 3.0 is released! This release brings us new improvements & features, like reduced bundle size, ESM support, and more.
read the article