Expand description
Template expression parser + AST. Per RFC-012.
This crate owns the pure half of pocopine’s expression
pipeline — lexer, parser, AST. The runtime evaluator
(pocopine_core::expr::evaluate) and the proc-macro
validator (pocopine_macros::for_plan, RFC 054) both depend
on this crate.
Splitting parser from evaluator lets the macro crate validate
template expressions at cargo check time without pulling in
wasm-bindgen / web-sys (host-incompatible).
Hand-rolled recursive descent so:
- the wasm bundle doesn’t pay for a parser-combinator crate,
- errors carry structured spans a future
.pocolanguage server can consume directly (no second parse), - the AST is trivially re-evaluable — the runtime caches it once per directive setup and walks it on every change.
Grammar (operator precedence, lowest → highest):
expr := stmt_seq
stmt_seq := stmt ( ';' stmt )* // RFC-024
stmt := assign | ternary
assign := path '=' ternary // RFC-024
ternary := logic_or ( '?' expr ':' expr )?
logic_or := logic_and ( '||' logic_and )*
logic_and := equality ( '&&' equality )*
equality := relation ( ( '==' | '!=' ) relation )*
relation := additive ( ( '<=' | '<' | '>=' | '>' ) additive )*
additive := unary ( '+' unary )*
unary := '!' unary | primary
primary := literal | path | call | '(' expr ')'
call := ident '(' ( ternary ( ',' ternary )* )? ')' // RFC-024
literal := string | number | 'true' | 'false' | 'null'
string := '"' [^"]* '"' | "'" [^']* "'"
number := /-?\d+(\.\d+)?/
path := ident ( '.' ident )*
ident := /[A-Za-z_$][A-Za-z0-9_$]*/Structs§
Enums§
Functions§
- parse
- Parse
srcinto a reusable AST. Returns structured errors with byte spans so a future.pocoLSP can surface them without a second parse.
Type Aliases§
- Span
- Byte-range span into the original source string.