Brainfuck runner - chosen to stress different corners of the library: operator precedence, recursive data, binders, comment-aware whitespace, and an esoteric language the parser also runs. The one big idea is that each grammar is written once over an abstract algebra - an
of builder functions its semantic actions call - then run two ways. Hand the grammar the language's meaningful actions and it yields a useful value: a number, a native Wolfram expression, a program's output. Hand it the shared
and the same grammar yields a standard, language-neutral syntax tree modelled on Wolfram's own
CodeParser
shape. That is the whole point: meaningful language-specific parse actions, but without which a standard AST. The grammar is untouched; only the algebra is swapped.
The standard AST
The neutral node vocabulary is core
Wolfram`Parser`
(the languages live in their own subcontexts,
Wolfram`Parser`Languages`Calculator`
and friends). Every node is a 3-slot triple
Head[descriptor,children,<|meta|>]
mirroring
CodeParser
, but the operator descriptors stay language-native strings (
"+"
,
":"
,
"'"
) instead of being forced into Wolfram symbols, so the same vocabulary serves a calculator, JSON, Lisp, the lambda calculus, and Brainfuck alike.
the algebra that folds to a numeric / symbolic value
JSON
A complete RFC 8259 reader. Objects and arrays nest through recursion, and the grammar exercises string escapes and the number grammar; only escape-decoding and numeric reading delegate to the kernel.
-local symbol; it can be garbage-collected once the builder returns, silently breaking the recursion. Use the recursion-cell helpers instead, which wrap a stable global symbol the way the paclet's own EBNF front-end does: