LR(1) Parsers Part II. Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved.

Similar documents
LR(1) Parsers Part II. Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved.

LR(1) Parsers Part III Last Parsing Lecture. Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved.

Parsing VI LR(1) Parsers

Syntax Analysis, VII The Canonical LR(1) Table Construction. Comp 412 COMP 412 FALL Chapter 3 in EaC2e. source code. IR IR target.

Syntax Analysis, VII The Canonical LR(1) Table Construction. Comp 412

CS415 Compilers Syntax Analysis Bottom-up Parsing

Computer Science 160 Translation of Programming Languages

Syntax Analysis, VI Examples from LR Parsing. Comp 412

Administrivia. Test I during class on 10 March. Bottom-Up Parsing. Lecture An Introductory Example

Compiler Design Spring 2017

Parsing -3. A View During TD Parsing

EXAM. CS331 Compiler Design Spring Please read all instructions, including these, carefully

CS 406: Bottom-Up Parsing

Compiler Design 1. LR Parsing. Goutam Biswas. Lect 7

CS 314 Principles of Programming Languages

LR2: LR(0) Parsing. LR Parsing. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class

Shift-Reduce parser E + (E + (E) E [a-z] In each stage, we shift a symbol from the input to the stack, or reduce according to one of the rules.

1. For the following sub-problems, consider the following context-free grammar: S AA$ (1) A xa (2) A B (3) B yb (4)

Lecture 11 Sections 4.5, 4.7. Wed, Feb 18, 2009

Bottom-Up Parsing. Ÿ rm E + F *idÿ rm E +id*idÿ rm T +id*id. Ÿ rm F +id*id Ÿ rm id + id * id

Bottom up parsing. General idea LR(0) SLR LR(1) LALR To best exploit JavaCUP, should understand the theoretical basis (LR parsing);

1. For the following sub-problems, consider the following context-free grammar: S AB$ (1) A xax (2) A B (3) B yby (5) B A (6)

I 1 : {S S } I 2 : {S X ay, Y X } I 3 : {S Y } I 4 : {X b Y, Y X, X by, X c} I 5 : {X c } I 6 : {S Xa Y, Y X, X by, X c} I 7 : {X by } I 8 : {Y X }

Syntax Analysis (Part 2)

Lexical Analysis Part II: Constructing a Scanner from Regular Expressions

Why augment the grammar?

Lecture VII Part 2: Syntactic Analysis Bottom-up Parsing: LR Parsing. Prof. Bodik CS Berkley University 1

EXAM. CS331 Compiler Design Spring Please read all instructions, including these, carefully

Syntactic Analysis. Top-Down Parsing

CA Compiler Construction

Compiler Construction Lectures 13 16

Context free languages

CS415 Compilers Syntax Analysis Top-down Parsing

EXAM. Please read all instructions, including these, carefully NAME : Problem Max points Points 1 10 TOTAL 100

Introduction to Bottom-Up Parsing

Compiler Construction Lent Term 2015 Lectures (of 16)

Compiler Construction Lent Term 2015 Lectures (of 16)

Introduction to Bottom-Up Parsing

Announcements. H6 posted 2 days ago (due on Tue) Midterm went well: Very nice curve. Average 65% High score 74/75

1. For the following sub-problems, consider the following context-free grammar: S A$ (1) A xbc (2) A CB (3) B yb (4) C x (6)

Translator Design Lecture 16 Constructing SLR Parsing Tables

Introduction to Bottom-Up Parsing

THEORY OF COMPILATION

Introduction to Bottom-Up Parsing

Talen en Compilers. Johan Jeuring , period 2. October 29, Department of Information and Computing Sciences Utrecht University

CS153: Compilers Lecture 5: LL Parsing

Predictive parsing as a specific subclass of recursive descent parsing complexity comparisons with general parsing

Compiler Construction

CS20a: summary (Oct 24, 2002)

Parsing Algorithms. CS 4447/CS Stephen Watt University of Western Ontario

Everything You Always Wanted to Know About Parsing

Lexical Analysis: DFA Minimization & Wrap Up

CPS 220 Theory of Computation

Top-Down Parsing and Intro to Bottom-Up Parsing

Syntactical analysis. Syntactical analysis. Syntactical analysis. Syntactical analysis

CMSC 330: Organization of Programming Languages. Pushdown Automata Parsing

Compilers. Lexical analysis. Yannis Smaragdakis, U. Athens (original slides by Sam

Type 3 languages. Type 2 languages. Regular grammars Finite automata. Regular expressions. Type 2 grammars. Deterministic Nondeterministic.

Compiling Techniques

n Top-down parsing vs. bottom-up parsing n Top-down parsing n Introduction n A top-down depth-first parser (with backtracking)

CSE302: Compiler Design

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

Briefly on Bottom-up

Chapter 4: Bottom-up Analysis 106 / 338

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών. Lecture 7a Syntax Analysis Elias Athanasopoulos

CSE 105 THEORY OF COMPUTATION

Conflict Removal. Less Than, Equals ( <= ) Conflict

Syntax Analysis Part I

Syntax Analysis Part I. Position of a Parser in the Compiler Model. The Parser. Chapter 4

Proving languages to be nonregular

Syntax Directed Transla1on

INF5110 Compiler Construction

Bottom-Up Syntax Analysis

Compiler Design. Spring Syntactic Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

MA/CSSE 474 Theory of Computation

Syntax Analysis Part I

Parsing with CFGs L445 / L545 / B659. Dept. of Linguistics, Indiana University Spring Parsing with CFGs. Direction of processing

Parsing with CFGs. Direction of processing. Top-down. Bottom-up. Left-corner parsing. Chart parsing CYK. Earley 1 / 46.

Compiler Principles, PS4

Curs 8. LR(k) parsing. S.Motogna - FL&CD

Bottom-Up Syntax Analysis

Bottom-up syntactic parsing. LR(k) grammars. LR(0) grammars. Bottom-up parser. Definition Properties

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

10. The GNFA method is used to show that

Bottom-up syntactic parsing. LR(k) grammars. LR(0) grammars. Bottom-up parser. Definition Properties

Lexical Analysis. DFA Minimization & Equivalence to Regular Expressions

Syntax Analysis - Part 1. Syntax Analysis

A non-turing-recognizable language

Bottom-up syntactic parsing. LR(k) grammars. LR(0) grammars. Bottom-up parser. Definition Properties

CSE 355 Test 2, Fall 2016

Ambiguity, Precedence, Associativity & Top-Down Parsing. Lecture 9-10

Context-Free Grammars and Languages. Reading: Chapter 5

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

CS Pushdown Automata

V Honors Theory of Computation

TDDD65 Introduction to the Theory of Computation

Computational Linguistics II: Parsing

Material Covered on the Final

(pp ) PDAs and CFGs (Sec. 2.2)

Transcription:

LR(1) Parsers Part II Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved.

Building LR(1) Tables : ACTION and GOTO How do we build the parse tables for an LR(1) grammar? Use grammar to build model of Control DFA ACTION table provides actions to perform Reductions, shifts, or accept GOTO table tells us state to goto next If table construction succeeds, the grammar is LR(1) Succeeds means defines each table entry uniquely

Building LR(1) Tables: The Big Picture Model the state of the parser with LR(1) items Use two functions goto( s, X ) and closure( s ) goto() is analogous to move() in the subset construction closure() adds information to round out a state Build up the states and transition functions of the DFA This is a fixed-point algorithm Use this information to fill in the ACTION and GOTO tables

LR(1) Items We represent valid configuration of LR(1) parser with a data structure called an LR(1) item An LR(1) item is a pair [P, δ], where P is a production A β with a at some position in the rhs δ is a lookahead string (word or EOF ) The ( placeholder ) in an item indicates the position of the top of the stack

LR(1) Items [A βγ,a] means that input seen so far is consistent with use of A βγ immediately after the symbol on TOS possibility [A β γ,a] means that input seen so far is consistent with use of A βγ at this point in the parse, and that the parser has already recognized β (that is, β is on TOS) partially complete [A βγ,a] means that parser has seen βγ, and that a lookahead symbol of a is consistent with reducing to A. complete

LR(1) Items Production A β, β = B 1 B 2 B 3 and lookahead a, gives rise to 4 items [A B 1 B 2 B 3,a] [A B 1 B 2 B 3,a] [A B 1 B 2 B 3,a] [A B 1 B 2 B 3,a] The set of LR(1) items for a grammar is finite

Lookahead symbols? Helps to choose the correct reduction Lookaheads has no use, unless item has at right end In [A β,a], lookahead a implies reduction by A β { [A β,a],[b γ δ,b] }, lookahead of a reduce to A; lookahead in FIRST(δ) shift

LR(1) Table Construction : Overview Build Canonical Collection (CC) of sets of LR(1) Items, I Step 1: Start with initial state, s 0 [S S,EOF], along with any equivalent items Derive equivalent items as closure( s 0 ) Grammar has an unique goal symbol 7

LR(1) Table Construction : Overview Step 2: For each s k, and each symbol X, compute goto(s k,x) If the set is not already in CC, add it Record all the transitions created by goto( ) This eventually reaches a fixed point Step 3: Fill in the table from the collection of sets of LR(1) items The states of canonical collection are precisely the states of the Control DFA The construction traces the DFA s transitions 8

Computing Closures Closure(s) adds all the items implied by the items already in state s s [A β C δ,a] Closure([A β C δ,a]) adds [C τ,x] where C is on the lhs and each x FIRST(δa) Since βc δ is valid, any way to derive βc δ is valid

Closure algorithm Closure( s ) while ( s is still changing ) items [A β C δ,a] s productions C τ P x FIRST(δa) // δ might be ε if [C τ,x] s then s s { [C τ,x] } Classic fixed-point method Halts because s ITEMS Closure fills out a state

Closure algorithm Closure( s ) while ( s is still changing ) items [A β C δ,a] s productions C τ P x FIRST(δa) // δ might be ε if [C τ,x] s then s s { [C τ,x] } Classic fixed-point method Halts because s ITEMS Closure fills out a state

Closure algorithm Closure( s ) while ( s is still changing ) items [A β C δ,a] s productions C τ P x FIRST(δa) // δ might be ε if [C τ,x] s then s s { [C τ,x] } Classic fixed-point method Halts because s ITEMS Closure fills out a state

Closure algorithm Closure( s ) while ( s is still changing ) items [A β C δ,a] s productions C τ P x FIRST(δa) // δ might be ε if [C τ,x] s then s s { [C τ,x] } Classic fixed-point method Halts because s ITEMS Closure fills out a state

Closure algorithm Closure( s ) while ( s is still changing ) items [A β C δ,a] s productions C τ P x FIRST(δa) // δ might be ε if [C τ,x] s then s s { [C τ,x] } Classic fixed-point method Halts because s ITEMS Closure fills out a state

Example From SheepNoise Initial step builds the item [Goal SheepNoise,EOF] and takes its closure( ) Closure( [Goal SheepNoise,EOF] ) 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa # Item Derived from 1 [Goal SheepNoise,EOF] Original item 2 [SheepNoise SheepNoise baa, EOF] 1, δa is EOF 3 [SheepNoise baa, EOF] 1, δa is EOF 4 [SheepNoise SheepNoise baa, baa] 2, δa is baa baa 5 [SheepNoise baa, baa] 2, δa is baa baa So, S 0 is { [Goal SheepNoise,EOF], [SheepNoise SheepNoise baa,eof], [SheepNoise baa,eof], [SheepNoise SheepNoise baa,baa], [SheepNoise baa,baa] }

Computing Gotos Goto(s,x) computes state parser would reach if it recognized x while in state s Goto( { [A β X δ,a] }, X ) Produces [A βx δ,a] Creates new items & uses closure() to fill out the state

Goto Algorithm Goto( s, X ) new Ø items [A β X δ,a] s new new { [A βx δ,a] } return closure(new) Not a fixed-point method! Uses closure ( ) Goto() moves us forward

Example from SheepNoise S 0 is { [Goal SheepNoise,EOF], [SheepNoise SheepNoise baa,eof], [SheepNoise baa,eof], [SheepNoise SheepNoise baa,baa], [SheepNoise baa,baa] } Goto( S 0, baa ) Loop produces 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa Item Source [SheepNoise baa, EOF] Item 3 in s 0 [SheepNoise baa, baa] Item 5 in s 0 Closure adds nothing since is at end of rhs in each item In the construction, this produces s 2 { [SheepNoise baa, {EOF,baa}] } New, but obvious, notation for two distinct items [SheepNoise baa, EOF] & [SheepNoise baa, baa]

Canonical Collection Algorithm s 0 closure ( [S S,EOF] ) S { s 0 } k 1 while ( S is still changing ) s j S and x ( T NT ) t goto(s j,x) if t S then name t as s k S S { s k } record s j s k on x k k + 1 else t is s m S record s j s m on x Fixed-point computation Loop adds to S S 2 ITEMS, so S is finite

Example from SheepNoise Starts with S 0 S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } Iteration 1 computes S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } 0 0 Goal Goal SheepNoise 1 1 SheepNoise SheepNoise baa baa 2 2 baa baa

Example from SheepNoise S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } Nothing more to compute, since is at the end of every item in S 3. Iteration 2 computes S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 0 Goal Goal SheepNoise 1 1 SheepNoise SheepNoise baa baa 2 2 baa baa

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

Filling in the ACTION and GOTO Tables The algorithm x is the state number set S x S item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k

Filling in the ACTION and GOTO Tables The algorithm set S x S before T shift item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k

Filling in the ACTION and GOTO Tables The algorithm set S x S item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k have Goal accept

Filling in the ACTION and GOTO Tables The algorithm set S x S item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k at end reduce

Filling in the ACTION and GOTO Tables The algorithm set S x S item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k Fill GOTO table

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], before T shift k [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa if i is [A β aδ,b] and goto(s x,a) = S k, a T [SheepNoise SheepNoise baa, baa] } then ACTION[x,a] shift k

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = before T shift k { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } so, ACTION[s 0,baa] is shift S 2 (clause 1) (items define same entry) S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } so, ACTION[S 1,baa] is shift S 3 (clause 1) S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } so, ACTION[S 1,EOF] is accept (clause 2) S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa else if i is [S S,EOF] [SheepNoise SheepNoise baa, baa] } then ACTION[x,EOF] accept

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } ACTION[S 2,baa] is reduce 2 (clause 3) [SheepNoise SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa so, ACTION[S 2,EOF] is reduce 2 (clause 3) else if i is [A β,a] then ACTION[x,a] reduce A β

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } ACTION[S S 1 = Goto(S 3,EOF] 0, SheepNoise) = reduce 1 (clause 3) { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } ACTION[S 3,baa] is reduce 1, as well 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa else if i is [A β,a] then ACTION[x,a] reduce A β

Example from SheepNoise The GOTO Table records Goto transitions on NTs s 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } s 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } Puts s 1 in GOTO[s 0,SheepNoise] s 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } Based on T, not NT and written into the ACTION table s 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa Only 1 transition in the entire GOTO table Remember, we recorded these so we don t need to recompute them.

ACTION & GOTO Tables Here are the tables for the SheepNoise grammar The tables ACTION TABLE State EOF baa 0 shift 2 1 accept shift 3 2 reduce 2 reduce 2 3 reduce 1 reduce 1 GOTO TABLE State SheepNoise 0 1 1 0 2 0 3 0 The grammar 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

What can go wrong? Shift/reduce error What if set s contains [A β aγ,b] and [B β,a]? First item generates shift, second generates reduce Both set ACTION[s,a] cannot do both actions This is ambiguity, called a shift/reduce error Modify the grammar to eliminate it Shifting will often resolve it correctly (if-then-else)

What can go wrong? Reduce/reduce conflict What is set s contains [A γ, a] and [B γ, a]? Each generates reduce, but with a different production Both set ACTION[s,a] cannot do both reductions This ambiguity is called reduce/reduce conflict Modify the grammar to eliminate it (PL/I s overloading of (...)) In either case, the grammar is not LR(1)

Summary LR(1) items Creating ACTION and GOTO table What can go wrong?