moonpsecplay
github
two benches, nothing faked

Put a document
on the table.

Both benches call the library compiled from these sources to JavaScript and loaded beside this page. Nothing here is a recording.

bench a — cut a document
position—:—
found—
would accept—
waiting for the rest of the text

Drag the rule to cut the document anywhere. At each cut the reader says whether it is waiting for more, and what it would say if the text ended there — the two answers a parser has to give when its text arrives in pieces. Delete a bracket and watch the expectation change.

bench b — draw the table's tree —

The tree is what make_expr_parser built from the table: precedence and associativity are visible in its shape, not asserted afterwards. A boxed operator is a node, the lines under it are its operands, and the left-to-right order is the order the text was read in.

The glue is twelve lines of MoonBit. Each bench calls one function: cut(text, at) and expression(text), both taking a string and returning a string. Everything the page draws is computed by the library at the moment you type — the refusals, the positions, the expectations, and the tree.