Slide 2.6: Syntax diagrams
Slide 2.8: Parse trees
Home

Context-Free Grammars (Cont.)


Derivations
A grammar derives strings by beginning with the start symbol and repeatedly replacing a nonterminal by the body of a production for that nonterminal. The terminal strings that can be derived from the start symbol form the language of the grammar. Reconsider the grammar of simple arithmetic expressions:
   <exp> ::= <exp> <op> <exp> | ( <exp> ) | number
   <op>  ::= + |  | *
the following list shows two popular derivations, where the symbol denotes the relation encompassing one step of a derivation and the square brackets enclose the production used in that step: