Examples

Each example below is a complete, runnable grammar. Edit the grammar or input and the parse tree updates live.

Multilingual Identifier

Identifiers that allow letters from multiple scripts

Initializing WASM…

CSV

This covers a limited portion of CSV inputs, but it's a good demonstration of how powerful just three grammar rules can be. Val uses a not-predicate (!) to consume every character that isn't a comma or newline, which naturally handles empty fields between consecutive commas.

Initializing WASM…

JSON

This grammar encompasses the whole https://json.org standard.

Initializing WASM…

Arithmetic without left recursion

Operator precedence falls out of rule nesting: Term handles * and /; Expr handles + and -. Because Term is always resolved before Expr sees its result, multiplication binds tighter — no precedence declarations needed.

Initializing WASM…

Arithmetic with left recursion

The same language, expressed differently. Superscript numbers are precedence levels: higher binds tighter. Expr² '*' Expr³ means "a level-2 expression, then *, then a level-3 expression." The VM resolves left recursion through memoization — the grammar reads exactly like a textbook operator table.

Initializing WASM…

URL

Initializing WASM…

Error labels

Attach ^label to any sub-expression. When that position fails, the label names the error instead of a generic "unexpected character" message. Here the grammar has labels but no recovery rules — parsing stops at the first failure, but the error clearly says what was expected.

Initializing WASM…

Error recovery

Recovery rules are definitions that share a name with a label. When ^value fails, the parser runs value <- (!';' .)* — consuming input up to the next ; — then records an error node and continues. semi <- is an empty rule: it marks the missing ; without consuming anything. The result is a complete parse tree covering all three assignments, with an error node only where the value was missing.

Initializing WASM…