LR Parsing - Lecture Notes | Programming Languages | CS 4610, Study notes of Programming Languages

Material Type: Notes; Professor: Weimer; Class: Programming Languages; Subject: Computer Science; University: University of Virginia; Term: Spring 2008;

Typology: Study notes

Pre 2010

Uploaded on 03/10/2009

koofers-user-nv3
koofers-user-nv3 🇺🇸

8 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 415 Discussion Section Notes 4
Claire Le Goues
February 21, 2008
1 LR Parsing
We should practice.
Consider the following LR(0) grammar (borrowed from my recent CS 671 home-
work), with terminals {− ( )}:
S S
ST
S
TT
T(S)
Let’s work out the DFA for this on the board. We begin by adding a new start
symbol, S0, to our grammar...
S0S
S S
ST
S
TT
T(S)
The first state might look like:
1
pf3

Partial preview of the text

Download LR Parsing - Lecture Notes | Programming Languages | CS 4610 and more Study notes Programming Languages in PDF only on Docsity!

CS 415 – Discussion Section Notes 4

Claire Le Goues

February 21, 2008

1 LR Parsing

We should practice.

Consider the following LR(0) grammar (borrowed from my recent CS 671 home- work), with terminals {− ( )}:

S → −S

S → T

S → 

T → T −

T → (S)

Let’s work out the DFA for this on the board. We begin by adding a new start symbol, S′, to our grammar...

S′^ → S

S → −S

S → T

S → 

T → T −

T → (S)

The first state might look like:

S′^ → • S

S → • −S

S → • T

S → • 

T → • T −

T → • (S)

How do we do the rest?

That was fun. Next up: let’s make a parsing table from that DFA. (note: