2013 uw cse 401 michael ringenburg 33 example showing

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: 2011 up directly •  ProperVes –  Maintains leP associaVvely (if you interpret the parse tree the right way, i.e., use the correct semanCc acCons) •  Let’s demonstrate that this really does generate the equivalent language. Winter 2013 UW CSE 401 (Michael Ringenburg) 28 DerivaVons CSE341: Programming Languages CSE341: Programming1. expr ::= term exprtail Languages exprtail := Lecture 1 2. Lecture :1 + term exprtail 3. exprtail :: = ε Course Course Mechanics Mechanics ML 4. term ::= x Variable Bindings ML Variable Bindings Dan Grossman Fall 2011 Winter 2013 Dan Grossman Fall 2011 UW CSE 401 (Michael Ringenburg) 29 Another Way to Look at This CSE341: Programming CSE341: Programming Languages Languages •  Observe that expr ::= exprL+ term | term ecture 1 Lecture 1 Course Mechanics C generates ourseequence the s Mechanics ML Variable Bindings ML Variable Bindings (…((term + term) + term) + …) + term Dan Grossman Dan Grossman •  We can sugar the original Frall 2011o reflect this ule t Fall 2011 expr ::= term { + term }* •  This leads directly to parser code –  Just be sure to do the correct thing to handle associaVvity as the terms are parsed Winter 2013 UW CSE 401 (Michael Ringenburg) 30 Code for Expressions (1) CSE341: Programming...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online