|
Here is a context-free grammar for syntactically correct arithmetical expressions: |
|
Here is a context-free grammar for syntactically correct infix algebraic expressions in the variables x, y and z: |
|
:S -> T - S |
|
:T -> T / T |
|
This grammar can for example generate the string (x+y)*x+y*y*(x+x). |
|
:T -> z This grammar can for example generate the string (x+y)*x-z*y/(x+x). |