{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

04-AmbigPrecReduct

# 04-AmbigPrecReduct - Discussion#4 Ambiguity and Precedence...

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

Discussion #4 Chapter 10, Sections 1.6 1/17 Discussion #4 Ambiguity and Precedence Grammars, Grammar Reductions

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

View Full Document
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

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

View Full Document
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

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern