Pattern Abstract Grammar

Pattern Abstract Grammar

Structured instructions for LLMs

BNF grammarA1

PAG is defined by a context-free grammar written in Backus–Naur form (BNF), and its rules fall into five categories. The planning and coordination productions are the grammar's own records, each grounded to a reasoning record, and the statement, expression and flowchart rules expand the terminals those records leave open. The scan described in well-formedness reads tokens rather than patterns, although the grammar itself admits a pattern literal in a condition.

Planning rulesA1.1

These rules cover document structure, the meta block, nodes, contracts, handoff gates, invariant records and the report.

Statement rulesA1.2

These rules cover directives, actions, control flow and declarations.

Expression rulesA1.3

These rules cover expressions, operators, literals and lexical elements.

Coordination rulesA1.4

These rules cover the structure declarations, the shared surface and the semantic operations.

Flowchart rulesA1.5

These rules cover flowcharts written in PAG's own form, in ASCII and in Mermaid.