Chapter 4: Syntax Analysis

Issues in bottom up parsing

. How do we know which action to take

- whether to shift or reduce

- Which production to use for reduction?

. Sometimes parser can reduce but it should not: X ε can always be reduced!

. Sometimes parser can reduce in different ways!

. Given stack d and input symbol a, should the parser

- Shift a onto stack (making it d a)

- Reduce by some production A ß assuming that stack has form αß (making it α A)

- Stack can have many combinations of αß

- How to keep track of length of ß ?

There are several issues in bottom up parsing:

. Making a decision as to which action (shift or reduce) to take next is an issue. Another question is which production to use for reduction, if a reduction has to be done.

. If there is a production of the form X ε , then we can introduce any number of X 's on the left side of the ' . ' (e.g., X and XX can derive the same string). In such cases we may not want the parser to reduce the epsilons to X's.

. A parser can reduce in different ways. For example, let the grammar be

S aABe

A Abc | b

B d

then reduction of string " a b b c d e " can be done in the following two ways (3rd line).

a b b c d e a b b c d e

a A b c d e a A b c d e

a A d e a A A c d e