Chapter 4: Syntax Analysis

Viable prefixes

.α is a viable prefix of the grammar if

- There is a w such that α w is a right sentential form

- α .w is a configuration of the shift reduce parser

. As long as the parser has viable prefixes on the stack no parser error has been seen

. The set of viable prefixes is a regular language (not obvious)

. Construct an automaton that accepts viable prefixes

The set of prefixes of right sequential forms that can appear on the stack of a shift-reduce parser are called viable prefixes. It is always possible to add terminal symbols to the end of a viable prefix to obtain a right-sentential form. Thus, as long as we are able to reduce the portion on the stack to a viable prefix, we are safe and no error occurs. Or to say, the input is accepted by the parser if we are able to manage viable prefixes as we consume the input, and at the last, we are left with the start symbol on the stack. The set of viable prefixes is a regular expression. This is not so obvious, but soon we are going to define the states for such an automaton which can accept viable prefixes.