Chapter 4: Syntax Analysis

Example

Parse tree for 9-5+2

The parse tree for 9-5+2 implied by the derivation in one of the previous slides is shown.

. 9 is a list by production (3), since 9 is a digit.

. 9-5 is a list by production (2), since 9 is a list and 5 is a digit.

. 9-5+2 is a list by production (1), since 9-5 is a list and 2 is a digit.

Production 1: list list + digit

Production 2: list list - digit

Production 3: list digit

digit 0|1|2|3|4|5|6|7|8|9