.agents/skills/xtext-to-langium/SKILL.md
This skill should be used when the user asks to "port an Xtext grammar to Langium", "migrate from Xtext to Langium", "convert Xtext grammar", "translate .xtext to .langium", "replace EMF metamodel with Langium AST", "port Xcore operations to TypeScript", "handle syntactic predicates in Langium", "restructure LL(*) grammar for LL(k)", "port Xtext scoping to Langium ScopeProvider", "port Xtext validation rules", or mentions migrating any Eclipse Xtext DSL to TypeScript/Langium.
npx skillsauth add pradeepmouli/rune-langium xtext-to-langiumInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Comprehensive guide for porting Eclipse Xtext grammars to Langium, covering grammar translation, EMF metamodel replacement, scoping, validation, and packaging as a TypeScript library.
Apply this skill when:
.xtext grammar to Langium .langium formatScopeProvider to Langium's scoping servicesDo not rely on xtext2langium for non-trivial grammars. Automated tools fail on:
=> and ->) requiring case-by-case LL(k) analysisApproach: Translate rule-by-rule, phase-by-phase, starting with the highest-risk subsystem (typically expressions).
Let Langium infer the AST from the grammar. Langium generates ast.ts with all node interfaces automatically.
Xtext uses ANTLR LL(*) with unlimited lookahead. Langium uses Chevrotain LL(k) with bounded lookahead.
| Xtext Pattern | Langium Strategy |
|---|---|
| => syntactic predicate | Restructure rule or increase maxLookahead |
| -> backtracking predicate | Eliminate via rule factoring |
| Deep lookahead | Gate on keywords or use Langium actions |
| < ambiguity (doc vs operator) | Separate terminal rules or keyword gating |
Start with maxLookahead: 3. Increase only for specific rules that fail.
Map each Xtext EReference scoping case to Langium's ScopeComputation + ScopeProvider services. Langium defaults handle simple containment cases (~5 of a typical 20+). The remaining cases require a custom scope provider.
Port validation rules incrementally by category, targeting 80% parity:
Execute in this order to retire risk early:
Set up monorepo, Langium config, terminal rules, skeleton entry rule, langium-cli generate pipeline, Vitest harness.
Checkpoint: langium-cli generate produces ast.ts. parse("") returns empty model.
Port the most complex grammar subsystem first. For typical DSLs this is expressions with precedence chains, postfix operators, and functional operations.
Checkpoint: All expression tests pass. Generated ast.ts contains typed expression interfaces.
Port data types, enumerations, functions, and other structural constructs. Implement parse() and parseWorkspace() APIs.
Checkpoint: Core types parse. Cross-references resolve. Public API works.
Implement custom scope provider. Port validation rules by category.
Checkpoint: 80%+ validation parity. Zero false positives on test corpus.
Port remaining subsystems (synonyms, annotations, reporting, external sources). Implement round-trip serialization.
Checkpoint: 100% test corpus parse rate. Round-trip passes.
Finalize exports, CLI, CI, browser testing, performance benchmarks, npm publish.
| Xtext | Langium |
|---|---|
| grammar G with org.eclipse.xtext.common.Terminals | grammar G (terminals defined inline) |
| returns TypeName | returns TypeName (same) |
| {Action} | {infer Action} |
| [TypeRef\|ID] | [TypeRef:ID] |
| current | infer keyword in actions |
| -> (backtrack) | Remove; restructure rule |
| => (synpred) | Remove; restructure for LL(k) |
| terminal fragment | terminal fragment (same) |
| @Override | Not needed; override via DI |
Build as a zero-dependency library (beyond langium + chevrotain):
For detailed patterns and techniques, consult:
references/grammar-patterns.md - Detailed grammar translation patterns including precedence chains, predicate elimination, action patterns, and the "without left parameter" redesignreferences/scoping-validation.md - Comprehensive scoping implementation guide with case-by-case dispatch patterns, and validation rule porting strategiesreferences/project-structure.md - Monorepo layout, build configuration, test fixture strategy, CI setup, and npm packagingexamples/expression-grammar.langium - Example Langium grammar fragment showing a 10-level expression precedence chainexamples/scope-provider.ts - Example custom ScopeProvider skeleton for a ported DSLtools
Router skill for the rune-langium monorepo. Use it to choose the right package skill before working in core, cli, lsp-server, codegen, or visual-editor.
tools
Router skill for the rune-langium monorepo. Use it to choose the right package skill before working in core, cli, lsp-server, codegen, or visual-editor.
tools
Langium port for Rune DSL tooling Use when working with rune, rosetta, dsl, langium, cdm, isda, drr, finos, language-server, lsp, visual-editor, reactflow.
tools
Langium port for Rune DSL tooling Use when working with rune, rosetta, dsl, langium, cdm, isda, drr, finos, language-server, lsp, visual-editor, reactflow.