Skip to content
Ronald Franco edited this page Dec 26, 2018 · 3 revisions

The syntax of an Attribute-Flow Grammar is similar to that of Attribute Grammars written in Extended Backus-Naur Form (EBNF).

Key Differences:

  1. Grammar productions are specified with an equal sign (=) instead of an arrow (->) and end with a semicolon (;).
    • EBNF: S -> A
    • AFG: S = A;
  2. Sequential grammar symbols are separated by the binary AND operator (&)
    • EBNF: S -> A B
    • AFG: S = A & B;
  3. Grammar symbol operators appear on the left of the grammar symbol operand as opposed to EBNF notation where the operator appears to the right of the grammar symbol operand
    • EBNF: S -> A*;
    • AFG: S = *A;

The following table illustrates all the operations available to be performed on grammar symbols in an AFG.

X & Y                concatenation
X | Y                alternation
*X                   repeat
+X                   nonzero repeat
-X                   optional
~X                   lookahead (match and backtrack)
!X                   negative lookahead (non-match and backtrack)
N * X                repeat N times
N-M * X              repeat N to M times
[&]{ ... }           semantic action
Token('A')           a token with code 65 (ASCII value of 'A')
Token(65)            a token with code 65
Clone this wiki locally