pocopine-expr 0.1.0

Pure-Rust template expression parser shared between pocopine-core (runtime evaluator) and pocopine-macros (compile-time validation). RFC 012 grammar.
Documentation
  • Coverage
  • 23.53%
    8 out of 34 items documented0 out of 6 items with examples
  • Size
  • Source code size: 43.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 903.22 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • mambisi/pocopine
    2 0 6
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mambisi

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 .poco language 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_$]*/