-
Notifications
You must be signed in to change notification settings - Fork 0
String Engine
Pt edited this page Jun 17, 2026
·
1 revision
String Engine is the textual backend in Lc.
It is suitable for:
- command-oriented runtimes,
- script-like processing layers,
- language-front execution stages,
- text transformation and compilation steps.
- Input stored in
INPUT string. - Parser returns
[]ParsedNode. - Parsed nodes stored in
PARSED []ParsedNode. - Runtime dispatches command handlers by
ParsedNode.Switch. - Handlers write to
UEP.Generator.
All parser results has automatic __prev / __next node references.
Use when you need:
- regex grammar matching,
- multiline continuation support,
- bracket-balance parsing,
- capture-group metadata extraction.
Use when lines follow command args shape.
- command ->
Switch - rest of line -> metadata args
Use when tokenization is a separate concern:
- ordered regexp2 matching,
- named metadata groups,
Registration:
NewCommandString(cmdSwitch, handler, doc)
Handler signature:
func(*engine.StringEngine, stringParsing.ParsedNode) error
Recommended behavior:
- validate metadata early,
- keep side effects explicit,
- write deterministic output to known pipeline points,
- return typed/context-rich errors.
Typical metadata keys:
- parser-defined capture groups,
-
__raw, -
__value(lexer), -
__prev,__next.
In large projects, treat metadata as schema:
- define key constants centrally,
- version key contracts with parser evolution.
Write:
Generator.AddString(...)Generator.AddStrings(...)
Read:
Generator.GetStringArrRes()Generator.GetStringRes(sep)
Use explicit pipeline points to separate runtime phases.