Lecture 5

# Winter 2013 uw cse 401 michael ringenburg 48 another

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

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

Unformatted text preview: = expr + expr | expr - expr | expr * expr | expr / expr | int int ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Winter 2013 UW CSE 401 (Michael Ringenburg) 42 What’s going on here? C •  CSE341: Programming oQon of precedence or The grammar SE341: Programming Languages has no n Languages associaQvely ecture 1 Lecture 1 L Course Mechanics •  TradiQonal soluQon Course Mechanics ML ML non- terminal Variable Bindings –  Create aVariable Bindings level of precedence for each –  Isolate the corresponding part of the grammar Dan Grossman Dan Grossman Fall higher –  Force the parser to recognize 2011 precedence Fall 2011 subexpressions ﬁrst –  Use leg- or right- recursion for leg- or right- associaQve operators •  E.g., E ::= E + F for leg associaQve addiQon Winter 2013 UW CSE 401 (Michael Ringenburg) 43 Classic Unambiguous Expression Grammar CSE341: Programming Languages exprC:= expr +Programming term | term :SE341: term | expr – Languages Lecture 1 term ::= term * factor | term / Lactor |1 actor fecture f Course Course Mechanics Mechanics factor ::= int | ( expr ) ML Variable Bindings ML Variable Bindings int ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Dan Grossman Fall 2011 Winter 2013 Dan Grossman Fall 2011 UW CSE 401 (Michael Ringenburg) 44 Check: Derive 2 + 3 * 4 CSE341: Programming CSE341: Programming Languages Languages Lecture 1 Lecture 1 Course Course Mechanics Mechanics ML Variable Bindings ML Variable Bindings Dan Grossman Fall 2011 Dan Grossman Fall 2011 expr ::= expr + term | expr – term | term term ::= term * factor | term / factor | factor factor ::= int | ( expr ) int...
View Full Document

## This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online