rune-langium / core/src / RuneDslParser
Class: RuneDslParser
Defined in: packages/core/src/services/rune-dsl-parser.ts:47
Custom Langium parser for the Rune DSL that pre-processes input text to insert implicit [ and ] brackets around bare expressions after extract, filter, and reduce operators.
Remarks
In the original Xtext-based Rune DSL, extract/filter/reduce can accept both bracket-delimited inline functions (extract [body]) and bare expressions (extract FuncName(item)), using the => syntactic predicate to resolve the ambiguity. Langium's LL(k) parser (Chevrotain) cannot replicate this — adding both alternatives causes the parser builder to hang indefinitely during FIRST(k) set computation.
This class works around the limitation by transforming the input text before parsing via insertImplicitBrackets: bare expressions after extract/filter/reduce are wrapped in [ and ] so the standard InlineFunction grammar rule handles them transparently.
Pitfalls
- The text pre-processor is regex-based and operates on raw source text before tokenization. It cannot correctly handle multi-line bare expressions that span a block boundary — always use explicit
[]brackets in those cases. - Do NOT regenerate
ast.tswhile TypeScript is watching the project — the generated file will be partially written and TypeScript will pick up an inconsistent version, causing spurious type errors. Stop the watcher first, regenerate, then restart.
Use When
- This is used automatically by
createRuneDslServices()— you do not need to instantiate it directly.
Avoid When
- Subclassing for grammar experiments — prefer creating a separate grammar variant and a new services container instead.
See
Extends
LangiumParser
Constructors
Constructor
new RuneDslParser(services): RuneDslParser;Defined in: packages/core/src/services/rune-dsl-parser.ts:48
Parameters
| Parameter | Type |
|---|---|
services | LangiumCoreServices |
Returns
RuneDslParser
Overrides
LangiumParser.constructorProperties
Accessors
definitionErrors
Get Signature
get definitionErrors(): IParserDefinitionError[];Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:144
Returns
IParserDefinitionError[]
Inherited from
LangiumParser.definitionErrorsunorderedGroups
Get Signature
get unorderedGroups(): Map<string, boolean[]>;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:103
Current state of the unordered groups
Returns
Map<string, boolean[]>
Inherited from
LangiumParser.unorderedGroupsMethods
action()
action($type, action): void;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:138
Parameters
| Parameter | Type |
|---|---|
$type | string |
action | Action |
Returns
void
Inherited from
LangiumParser.actionalternatives()
alternatives(idx, choices): void;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:93
Performs alternatives parsing (the | operation in EBNF/Langium)
Parameters
| Parameter | Type |
|---|---|
idx | number |
choices | IOrAlt<any>[] |
Returns
void
Inherited from
LangiumParser.alternativesatLeastOne()
atLeastOne(idx, callback): void;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:96
Parses the callback 1 or more times (the + operation in EBNF/Langium)
Parameters
| Parameter | Type |
|---|---|
idx | number |
callback | DSLMethodOpts<unknown> |
Returns
void
Inherited from
LangiumParser.atLeastOneconsume()
consume(
idx,
tokenType,
feature): void;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:128
Parameters
| Parameter | Type |
|---|---|
idx | number |
tokenType | TokenType |
feature | AbstractElement |
Returns
void
Inherited from
LangiumParser.consumefinalize()
finalize(): void;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:105
Returns
void
Inherited from
LangiumParser.finalizegetRule()
getRule(name): RuleResult | undefined;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:101
Returns the executable rule function for the specified rule name
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
RuleResult | undefined
Inherited from
LangiumParser.getRulegetRuleStack()
getRuleStack(): number[];Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:104
The rule stack indicates the indices of rules that are currently invoked, in order of their invocation.
Returns
number[]
Inherited from
LangiumParser.getRuleStackisRecording()
isRecording(): boolean;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:102
Whether the parser is currently actually in use or in "recording mode". Recording mode is activated once when the parser is analyzing itself. During this phase, no input exists and therefore no AST should be constructed
Returns
boolean
Inherited from
LangiumParser.isRecordingmany()
many(idx, callback): void;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:95
Parses the callback 0 or more times (the * operation in EBNF/Langium)
Parameters
| Parameter | Type |
|---|---|
idx | number |
callback | DSLMethodOpts<unknown> |
Returns
void
Inherited from
LangiumParser.manyoptional()
optional(idx, callback): void;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:94
Parses the callback as optional (the ? operation in EBNF/Langium)
Parameters
| Parameter | Type |
|---|---|
idx | number |
callback | DSLMethodOpts<unknown> |
Returns
void
Inherited from
LangiumParser.optionalparse()
parse<T>(input, options?): ParseResult<T>;Defined in: packages/core/src/services/rune-dsl-parser.ts:52
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends AstNode | AstNode |
Parameters
| Parameter | Type |
|---|---|
input | string |
options? | ParserOptions |
Returns
ParseResult<T>
Overrides
LangiumParser.parserule()
rule(rule, impl): RuleResult;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:121
Parameters
| Parameter | Type |
|---|---|
rule | InfixRule | ParserRule |
impl | RuleImpl |
Returns
RuleResult
Inherited from
LangiumParser.rulesubrule()
subrule(
idx,
rule,
fragment,
feature,
args): void;Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:136
Parameters
| Parameter | Type |
|---|---|
idx | number |
rule | RuleResult |
fragment | boolean |
feature | AbstractElement |
args | Args |
Returns
void
Inherited from
LangiumParser.subrule