Chapter 4:Syntax Analysis

Derivation .

. If in a sentential form only the leftmost non terminal is replaced then it becomes leftmost derivation

. Every leftmost step can be written as wAγ lm* wδγ where w is a string of terminals and A δ is a production

. Similarly, right most derivation can be defined

. An ambiguous grammar is one that produces more than one leftmost/rightmost derivation of a sentence

Consider the derivations in which only the leftmost non-terminal in any sentential form is replaced at each step. Such derivations are termed leftmost derivations. If a ß by a step in which the leftmost non-terminal in a is replaced, we write a lm ß . Using our notational conventions, every leftmost step can be written wAγlmwdγ where w consists of terminals only, A d is the production applied, and ? is a string of grammar symbols. If a derives ß by a leftmost derivation, then we write a lm* ß . If S lm* a , then we say a is a left-sentential form of the grammar at hand. Analogous definitions hold for rightmost derivations in which the rightmost non-terminal is replaced at each step. Rightmost derivations are sometimes called the canonical derivations. A grammar that produces more than one leftmost or more than one rightmost derivation for some sentence is said to be ambiguous . Put another way, an ambiguous grammar is one that produces more than one parse tree for some sentence is said to be ambiguous.