Type Editor / @type-editor/model / content-parser/ContentMatcher / ContentMatcher
Class: ContentMatcher
Defined in: packages/model/src/content-parser/ContentMatcher.ts:20
Compiles content expressions into a deterministic finite automaton (DFA).
The compilation process follows these steps:
- Build a Non-deterministic Finite Automaton (NFA) from the expression AST
- Convert the NFA to a DFA using subset construction
- Validate the DFA for dead-end states (non-generatable required content)
For background on NFA/DFA construction, see: https://swtch.com/~rsc/regexp/regexp1.html
Constructors
Constructor
new ContentMatcher(expression): ContentMatcher;Defined in: packages/model/src/content-parser/ContentMatcher.ts:35
Creates a new content matcher and compiles the expression into a DFA.
Parameters
| Parameter | Type | Description |
|---|---|---|
expression | ContentPattern | The parsed expression AST to compile |
Returns
ContentMatcher
Accessors
match
Get Signature
get match(): ContentMatch;Defined in: packages/model/src/content-parser/ContentMatcher.ts:46
Gets the compiled content match automaton.
Returns
The compiled ContentMatch DFA
Methods
getCheckedMatch()
getCheckedMatch(stream): ContentMatch;Defined in: packages/model/src/content-parser/ContentMatcher.ts:57
Gets the compiled content match after validating it for dead ends.
Parameters
| Parameter | Type | Description |
|---|---|---|
stream | TokenStream | The token stream (used for error reporting) |
Returns
The compiled and validated ContentMatch DFA
Throws
If the expression contains unreachable or non-generatable content