E := E '+' T
| T
T := T '*' F
| F
F := '(' E ')'
| 'id'
This Grammar has been taken from the Dragon book and is often used there in many examples.
S := L '=' R | R L := '*' R | 'id' R := L
This is a grammar from the Dragon book, it resembles the C pointer dereferencing and assignment syntax. It shows well that it is not a SLR(1) grammar but a LALR(1) grammar.
Grammatik := Regeln
Regeln := Regeln Regel
|
Regel := 'Bezeichner' '::=' Ausdruck '.'
Ausdruck := Elemente
| Elemente '|' Ausdruck
Elemente := Element Elemente
|
Element := Einheit '*'
| Einheit '+'
| '[' Ausdruck ']'
Einheit := Atom
| '(' Ausdruck ')'
Atom := 'Bezeichner'
| 'Literal'
This is a grammar of the syntax of EBNF. The non terminals are in German.
S := A 'a' | 'b' A 'c' | B 'c' | 'b' B 'a' A := 'd' B := 'd'
S := S S '+' | S S '*' | 'a'
S := S A | A A := 'a'
S := A S | 'b' A := S A | 'a'
S := S '(' S ')' S
|
S := S '+' S
| S S
| '(' S ')'
| S '*'
| 'a'
bexpr := bexpr 'or' bterm
| bterm
bterm := bterm 'and' bfactor
| bfactor
bfactor := 'not' bfactor
| '(' bexpr ')'
| 'true'
| 'false'
A := B | B 'x' B := 'y'