06-ParseRecursiveGram

# 06-ParseRecursiveGram - Discussion#6 Parsing Recursive...

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

Discussion #6 Chapter 10, Section 2 1/16 Discussion #6 Parsing Recursive Grammars

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

View Full Document
Discussion #6 Chapter 10, Section 2 2/16 Topics Tail recursion LL(1) with ε Table driven LL(1) with ε Lexical Analyzers
Discussion #6 Chapter 10, Section 2 3/16 Motivating Example Let’s use integers instead of digits in our prefix language. What’s the problem with *2+72100? Syntax error? Or is it simply ambiguous? * 2 + 7 2100 = 2 * (7 + 2100) = 4214? * 2 + 72 100 = 2 * (72+100) = 344? Solutions? Let n mark the beginning of a number e.g. * n2 + n72 n100 = 2 * (72 + 100) = 344 Strange: but you’ll soon see where we are headed and why.

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

View Full Document
Discussion #6 Chapter 10, Section 2 4/16 E (1) N | (2) OEE O (3) + | (4) * N (5) nI I (6) D | (7) ID D (8) 0 | (9) 1 | … | (17) 9 E I D n 2 O E E N N + I n D I D I D 1 0 0 I n D I D 7 2 N O E E * Consider: * n2 + n72 n100
Discussion #6 Chapter 10, Section 2 5/16 E (1) N | (2) OEE O (3) + | (4) * N (5) nI I (6) D | (7) ID D (8) 0 | (9) 1 | … | (17) 9 E I D n 2 O E E N N + I n ?? N O E E * * n2 + n72 n100 Question… Which rule do we choose? I (6) D or I (7) ID We don’t know without looking further ahead. Should we look further ahead, or find another way?

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

View Full Document
Discussion #6 Chapter 10, Section 2 6/16 LL(1) with ε There is another way.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 13

06-ParseRecursiveGram - Discussion#6 Parsing Recursive...

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

View Full Document
Ask a homework question - tutors are online