CALM template DSL parser and sequence builder.
Template is a string with semicolon-separated entries.
| Template spec syntax | Description |
|---|---|
BOS | bare token |
CWD:cwd | simple frame: <CWD> bytes <END> |
ENV:env* | repeated frame: per item <ENV> bytes <END> |
COMP:completions+ | NEXT-separated list: <COMP> a <NEXT> b ... <END> |
HIST(cmd):history*/EXIT:exit | repeated with subtoken |
WORD:headword/POS:pos | frame with subtoken (non-repeated) |
WORD:input/ATN/POS:pos | frame_sub with embedded bare token |
ATN | bare |
CMD:input | last frame after ATN is terminal (no <END>) |
| Name | Signature |
|---|---|
parse | parse(spec) -> elements, err |
build | build(elements, opts, budget) -> tokens |
validate | validate(spec) -> ok, err |
parse(
spec) ->elements,err
Parse a template spec string into an element descriptor array
build(
elements,opts,budget) ->tokens
Build a token sequence from a parsed template and an opts table
validate(
spec) ->ok,err
Validate a template spec string