Skip to content

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.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:48

Parameters

ParameterType
servicesLangiumCoreServices

Returns

RuneDslParser

Overrides

ts
LangiumParser.constructor

Properties

PropertyModifierTypeInherited fromDefined in
_unorderedGroupsprotectedMap<string, boolean[]>LangiumParser._unorderedGroupsnode_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:89
allRulesprotectedMap<string, RuleResult>LangiumParser.allRulesnode_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:90
lexerreadonlyLexerLangiumParser.lexernode_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:87
mainRuleprotectedRuleResultLangiumParser.mainRulenode_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:91
wrapperreadonlyChevrotainWrapperLangiumParser.wrappernode_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:88

Accessors

definitionErrors

Get Signature

ts
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

ts
LangiumParser.definitionErrors

unorderedGroups

Get Signature

ts
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

ts
LangiumParser.unorderedGroups

Methods

action()

ts
action($type, action): void;

Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:138

Parameters

ParameterType
$typestring
actionAction

Returns

void

Inherited from

ts
LangiumParser.action

alternatives()

ts
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

ParameterType
idxnumber
choicesIOrAlt<any>[]

Returns

void

Inherited from

ts
LangiumParser.alternatives

atLeastOne()

ts
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

ParameterType
idxnumber
callbackDSLMethodOpts<unknown>

Returns

void

Inherited from

ts
LangiumParser.atLeastOne

consume()

ts
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

ParameterType
idxnumber
tokenTypeTokenType
featureAbstractElement

Returns

void

Inherited from

ts
LangiumParser.consume

finalize()

ts
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

ts
LangiumParser.finalize

getRule()

ts
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

ParameterType
namestring

Returns

RuleResult | undefined

Inherited from

ts
LangiumParser.getRule

getRuleStack()

ts
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

ts
LangiumParser.getRuleStack

isRecording()

ts
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

ts
LangiumParser.isRecording

many()

ts
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

ParameterType
idxnumber
callbackDSLMethodOpts<unknown>

Returns

void

Inherited from

ts
LangiumParser.many

optional()

ts
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

ParameterType
idxnumber
callbackDSLMethodOpts<unknown>

Returns

void

Inherited from

ts
LangiumParser.optional

parse()

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

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

Type Parameters

Type ParameterDefault type
T extends AstNodeAstNode

Parameters

ParameterType
inputstring
options?ParserOptions

Returns

ParseResult<T>

Overrides

ts
LangiumParser.parse

rule()

ts
rule(rule, impl): RuleResult;

Defined in: node_modules/.pnpm/langium@4.2.2/node_modules/langium/lib/parser/langium-parser.d.ts:121

Parameters

ParameterType
ruleInfixRule | ParserRule
implRuleImpl

Returns

RuleResult

Inherited from

ts
LangiumParser.rule

subrule()

ts
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

ParameterType
idxnumber
ruleRuleResult
fragmentboolean
featureAbstractElement
argsArgs

Returns

void

Inherited from

ts
LangiumParser.subrule

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