Dan grossman dan grossman gotouncovereds a is the 2011

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: t $s1 abbcde$ $s1as2 bbcde$ accept S$ start 8 B 1 a 2 A b b 3 6 e c 9 S ::= aABe 7 A ::= Abc d 4 5 A ::= b B ::= d ShiOed ‘a’ and state s2 on to stack, followed ‘a’ transiTon. ShiO again. Winter 2013 29 UW CSE 401 (Michael Ringenburg) S ::= aABe A ::= Abc | b B ::= d Trace Stack Input $s1 abbcde$ $s1as2 bbcde$ $s1as2bs4 bcde$ accept S$ start 8 B 1 a 2 b A 3 b 6 e c 9 S ::= aABe 7 A ::= Abc d 4 A ::= b 5 B ::= d ShiOed ‘b’ and state s4 on to stack, followed ‘b’ transiTon. Now, reduce. Winter 2013 UW CSE 401 (Michael Ringenburg) 30 15 1/23/13 S ::= aABe A ::= Abc | b B ::= d Trace Stack Input $s1 abbcde$ $s1as2 bbcde$ $s1as2bs4 bcde$ $s1as2 bcde$ accept S$ start 8 B 1 a 2 b A 3 b 6 e c 9 S ::= aABe 7 A ::= Abc d 4 A ::= b 5 B ::= d Pop handle (b), revealing new state s2. Go there. Winter 2013 31 UW CSE 401 (Michael Ringenburg) Trace accept S ::= aABe A ::= Abc | b B ::= d e 8 9 S ::= aABe Stack Input B S$ $s1 abbcde$ a start A b c 1 2 3 6 7 A ::= Abc $s1as2 bbcde$ b d $s1as2bs4 bcde$ 4 5 $s1as2As3 bcde$ A ::= b B ::= d •  Push nonterminal on leO of reducTon (A) onto stack, transiTon on new nonterminal, and push new state. •  Each step – read an input (shiO) or produce an output (reduce). O(n), where n is input + output. Winter 2013 UW CSE 401 (Michael Ringenburg) 32 16 1/23/13 Encoding the DFA in a Table CSE341: Programming CSE341: opTmizaTons, Languages Languages •  Given these Programming and a stack containing states, a shiO- reduce parser’s DFA can be encoded in Lecture 1 Lecture 1 two tables Course Course Mechanics Mechanics –  ac5on table rows contain state and columns contain input Mto VariablecBindings and next...
View Full Document

Ask a homework question - tutors are online