{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

04-AmbigPrecReduct

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

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

View Full Document Right Arrow Icon
Discussion #4 Chapter 10, Sections 1.6 1/17 Discussion #4 Ambiguity and Precedence Grammars, Grammar Reductions
Image of page 1

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

View Full Document Right Arrow Icon
Discussion #4 Chapter 10, Sections 1.6 2/17 Topics Ambiguity Precedence Grammars Grammar Reductions
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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.
Image of page 4
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
Image of page 5

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern