04-AmbigPrecReduct

04-AmbigPrecReduct - Discussion #4 Chapter 10, Sections 1.6...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Discussion #4 Chapter 10, Sections 1.6 1/17 Discussion #4 Ambiguity and Precedence Grammars, Grammar Reductions Discussion #4 Chapter 10, Sections 1.6 2/17 Topics Ambiguity Precedence Grammars Grammar Reductions Discussion #4 Chapter 10, Sections 1.6 3/17 Problems with Grammars We are heading towards grammars that are reasonable , get the job done , and for which we can find efficient parsing algorithms . Not all grammars are usable! Ambiguous Silly Have unproductive non-terminals Have unreachable rules Discussion #4 Chapter 10, Sections 1.6 4/17 Ambiguous Grammars A grammar for which there are two different parse trees for the same terminal string is said to be ambiguous . We can show that a grammar is ambiguous by giving two parse trees for the same terminal string. Discussion #4 Chapter 10, Sections 1.6 5/17 = { E D | ( E ) | E + E | E E | E * E | E / E , D 0 | 1 | | 9 } E E E + E E * D D D 1 2 3 1 + 2 * 3 E E E * E E + D D D 1 2 3 1 + 2 * 3 An Ambiguous Grammar Discussion #4 Chapter 10, Sections 1.6 6/17 Ambiguity & Multiple Meanings Precedence: (1+2)*3 1+(2*3) Associativity: (3- 2)- 1 3- (2- 1) Different if-then-else nestings Discussion #4...
View Full Document

Page1 / 17

04-AmbigPrecReduct - Discussion #4 Chapter 10, Sections 1.6...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online