PEGO

E040: Recognition Lowering

Recognition checks conformance without publishing a parse tree. A separate compiled program avoids unused values and actions while retaining the values needed to decide predicates.

Mechanism and Invariants

Program.Recognizer builds a separate rule graph with independent memo identities. Unused captures and actions are omitted; value-producing actions required by predicates still execute and can fail. Syntax errors, recovered errors and matching rollback preserve the recognition contract. Recognition is an explicitly selected operation, not the ordinary full parse with a hidden optimization flag.

Scope and State

Engine recognition is available in closure and both VMs when the grammar is present. Generated Go and TypeScript emit recognition when requested; typed Go packages use their generated recognition entry point rather than constructing typed output. The default full-parse operation remains valued.

In generated Node parsers, the recognition rules are printed from Flow IR: the lean value-free rules as direct rules and the others as framed bodies, in every build form. The first-character guards of the Flow copy are built after the Analyze pass, as in the table pipeline.

Reference Control

No separate same-operation all-valued recognition comparator is maintained. Comparing Parse with Recognize measures different requested results, and does not isolate any one value-elision mechanism.

Evidence and Implementation

Historical record 007 measures recognition about 1.5–1.8 times faster than full parsing; 047 reports generated recognition versus Node parsing. These are operation comparisons with their stated workloads, not mechanism ablations or equivalent-output decoder comparisons.

Evidence records: 007, 047.

Source owners: Program.Recognizer, recognize compilation and predicate capture analysis, recognizer generation, generated recognize entry point.

The comparison policy distinguishes same-source controls, historical changes and full checkpoints.

Related mechanisms: E010, G020, A160.

Optimization Catalog