{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 10-LR-Parsing - CS 421 Lecture 9 LR parsing and resolving...

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

CS 421 Lecture 9: LR parsing and resolving conflicts s Review s Top-down parsing s Bottom-up parsing s Lecture outline s What are conflicts? s Using parse trees to understand conflicts s Fixing conflicts s Eliminating conflicts using %prec declarations 6/22/2009 1

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

View Full Document
Review: Top-down parsing s A.K.A. recursive descent s One parse function per non-terminal s Ambiguity s LL(1) condition s Parse tree construction s Precedence s Associativity s How do we choose which production to apply? 6/22/2009 2
Review: Bottom-up parsing s A.K.A. shift-reduce s Keep a stack of partial parse trees s Automatic parser generation (ocamlyacc) s Actions s Shift s Reduce s Accept s Reject s How to decide which action to take? s Today: dealing with conflicts 6/22/2009 3

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

View Full Document
Conflicts s Big question: how to choose whether to shift or reduce? s ocamlyacc uses a method – called LALR(1) – to construct tables that say which action to take s There are times when there is no good way to make this decision s ocamlyacc will reject grammar and give an error message s In bottom-up parsing, these are called conflicts s As with top-down parsing, these problems can sometimes be resolved by modifying the grammar. 6/22/2009 4
Conflicts s Ocamlyacc generates tables saying which action to take at each point in the parse s Method is called “LALR(1)” s “LR(1)” is a similar, but somewhat more powerful, method. Will often use “LR(1)” and “LALR(1)” as synonyms. ot every grammar can be parsed using this method

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 24

10-LR-Parsing - CS 421 Lecture 9 LR parsing and resolving...

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

View Full Document
Ask a homework question - tutors are online