Skip to content

rune-langium / core/src / RuneDslParser

Class: RuneDslParser ​

Defined in: packages/core/src/services/rune-dsl-parser.ts:48

Custom Langium parser for the Rune DSL that normalizes lexer input 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 lexer input using the same scanner as insertImplicitBrackets: bare expressions after extract/filter/reduce are wrapped in [ and ] so the standard InlineFunction grammar rule handles them transparently. Lexer locations are mapped back before parsing, so the CST and all downstream source regions use the original text. Synthetic brackets have empty images and zero-width CST ranges.

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.ts while 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 ​

ts
new RuneDslParser(services): RuneDslParser;

Defined in: packages/core/src/services/rune-dsl-parser.ts:51

Parameters ​

ParameterType
servicesLangiumCoreServices

Returns ​

RuneDslParser

Overrides ​

LangiumParser.constructor

Properties ​

PropertyModifierTypeOverridesInherited fromDefined in
_unorderedGroupsprotectedMap<string, boolean[]>-LangiumParser._unorderedGroupsnode_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:89
allRulesprotectedMap<string, RuleResult>-LangiumParser.allRulesnode_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:90
lexerprotected readonlyLexerLangiumParser.lexer-packages/core/src/services/rune-dsl-parser.ts:49
mainRuleprotectedRuleResult-LangiumParser.mainRulenode_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:91
wrapperprotected readonlyChevrotainWrapper-LangiumParser.wrappernode_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:88

Accessors ​

definitionErrors ​

Get Signature ​

ts
get definitionErrors(): IParserDefinitionError[];

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:152

Returns ​

IParserDefinitionError[]

Inherited from ​

LangiumParser.definitionErrors


unorderedGroups ​

Get Signature ​

ts
get unorderedGroups(): Map<string, boolean[]>;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:103

Current state of the unordered groups

Returns ​

Map<string, boolean[]>

Inherited from ​

LangiumParser.unorderedGroups

Methods ​

action() ​

ts
action($type, action): void;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:146

Parameters ​

ParameterType
$typestring
actionAction

Returns ​

void

Inherited from ​

LangiumParser.action


alternatives() ​

ts
alternatives(idx, choices): void;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:93

Performs alternatives parsing (the | operation in EBNF/Langium)

Parameters ​

ParameterType
idxnumber
choicesIOrAlt<any>[]

Returns ​

void

Inherited from ​

LangiumParser.alternatives


atLeastOne() ​

ts
atLeastOne(idx, callback): void;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:96

Parses the callback 1 or more times (the + operation in EBNF/Langium)

Parameters ​

ParameterType
idxnumber
callbackDSLMethodOpts<unknown>

Returns ​

void

Inherited from ​

LangiumParser.atLeastOne


consume() ​

ts
consume(
   idx, 
   tokenType, 
   feature
): void;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:136

Parameters ​

ParameterType
idxnumber
tokenTypeTokenType
featureAbstractElement

Returns ​

void

Inherited from ​

LangiumParser.consume


finalize() ​

ts
finalize(): void;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:105

Returns ​

void

Inherited from ​

LangiumParser.finalize


getRule() ​

ts
getRule(name): RuleResult | undefined;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:101

Returns the executable rule function for the specified rule name

Parameters ​

ParameterType
namestring

Returns ​

RuleResult | undefined

Inherited from ​

LangiumParser.getRule


getRuleStack() ​

ts
getRuleStack(): number[];

Defined in: node_modules/.pnpm/[email protected]/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.getRuleStack


isRecording() ​

ts
isRecording(): boolean;

Defined in: node_modules/.pnpm/[email protected]/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.isRecording


many() ​

ts
many(idx, callback): void;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:95

Parses the callback 0 or more times (the * operation in EBNF/Langium)

Parameters ​

ParameterType
idxnumber
callbackDSLMethodOpts<unknown>

Returns ​

void

Inherited from ​

LangiumParser.many


optional() ​

ts
optional(idx, callback): void;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:94

Parses the callback as optional (the ? operation in EBNF/Langium)

Parameters ​

ParameterType
idxnumber
callbackDSLMethodOpts<unknown>

Returns ​

void

Inherited from ​

LangiumParser.optional


parse() ​

ts
parse<T>(input, options?): ParseResult<T>;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:124

Type Parameters ​

Type ParameterDefault type
T extends AstNodeAstNode

Parameters ​

ParameterType
inputstring
options?ParserOptions

Returns ​

ParseResult<T>

Inherited from ​

LangiumParser.parse


rule() ​

ts
rule(rule, impl): RuleResult;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:121

Parameters ​

ParameterType
ruleParserRule | InfixRule
implRuleImpl

Returns ​

RuleResult

Inherited from ​

LangiumParser.rule


subrule() ​

ts
subrule(
   idx, 
   rule, 
   fragment, 
   feature, 
   args
): void;

Defined in: node_modules/.pnpm/[email protected]/node_modules/langium/lib/parser/langium-parser.d.ts:144

Parameters ​

ParameterType
idxnumber
ruleRuleResult
fragmentboolean
featureAbstractElement
argsArgs

Returns ​

void

Inherited from ​

LangiumParser.subrule

Core packages released under MIT. Studio app released under FSL-1.1-ALv2.