Factor dan grossman symbol is times while next symbol

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: 1 L | term Course Mechanics expr() { void Course Mechanics expr(); ML Variable Bindings ML Variable Bindings if (current token is Dan PLUS) { Grossman Dan Grossman Fall 2011 getNextToken(); Fall 2011 term(); } •  And the bug is???? } Winter 2013 UW CSE 401 (Michael Ringenburg) 26 LeP Recursion Problem CSE341: Programming CSE341: Programming Languages Languages •  If we code up a leP- recursive rule as- is, we get Lecture an infinite recursion 1 Lecture 1 Course Course Mechanics Mechanics •  Non- soluVon: replace with a right- recursive ML Variable Bindings ML Variable Bindings rule Dan Grossman Dan Grossman expr ::= term + expr | tFall 2011 erm Fall 2011 –  Why isn’t this the right thing to do? Winter 2013 UW CSE 401 (Michael Ringenburg) 27 One LeP Recursion SoluVon CSE341: Programming CSE341: Programming Languages Languages •  Rewrite using right recursion and a new non- terminal •  Original: expr ::= ecturet1 Lecture 1 L expr + erm | term Course •  New Course Mechanics Mechanics expr ::= term exprtail Bindings ML Variable ML Variable Bindings exprtail ::= + term exprtail | ε Dan Grossman Dan Grossman Fall 2011 Fall f coded –  No infinite recursion i...
View Full Document

Ask a homework question - tutors are online