Module Wax_wasm.RecoverSource

Sync-token classification for the WAT parser's panic-mode error recovery.

Classify a WAT token for Parsing.Make.parse_recover: every opening parenthesis (bare LPAREN and the compound (param/… tokens) is Open, RPAREN is Close, end-of-input is Terminal, and everything else is Skip. WAT being fully parenthesized, the parentheses are the only resynchronization points; recovery relies on the nesting-aware skip and on auto-closing with closers.

Sourceval closers : Tokens.token list

The closing brackets (")") Parsing.Make.parse_recover may insert to auto-close a construct still open in front of a boundary or at end of input. Passed as its ?closers argument.

Placeholder tokens Parsing.Make.parse_recover may insert to repair a construct missing a required token — a zero-width 0 for a missing numeric operand or index — each with the diagnostic to report. Passed as its ?insert argument.

Sourceval barrier : Tokens.token * (Tokens.token -> bool) * (Tokens.token -> bool)

The barrier Parsing.Make.parse_recover uses to recognize a missing closer (a new field offered where an instruction was expected) and restart at that field: the ( token to re-offer, the predicate for a field keyword written after a bare ( (offered as a pair), and the predicate for a fused (type/(import/(export opener (offered alone). Passed as its ?barrier argument.