Term dan grossman dan grossman while next symbol is

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: CSE341: Programming Languages Languages // parse // parse L// term 1:= factor { * factor }* ecture : // expr ::= term { + Lecture 1 term }* Course ExprNode exprCourse Mechanics Mechanics () { ExprNode term() { ML Variable Bindings p2; ExprNode op1, op2; ML Variable Bindings ExprNode op1, o op1 = term(); op1 = factor(); Dan Grossman symbol is TIMES) { while (next symbol is PLUS) { while (next Dan Grossman FallgetNextToken(); getNextToken(); Fall 2011 2011 op2 = term(); op2 = factor(); op1 = CreatePlusNode(op1, op2); op1 = CreateMultNode(op1, op2); } } return op1; return op1; } } Winter 2013 UW CSE 401 (Michael Ringenburg) 31 Code for Expressions (2) CSE341: Programming CSE341: Programming Languages Languages // parse Lecture 1 Lecture 1 // factor ::= int | id | ( expr ) c Course Mechanics Course Mechanicsase ID: ExprNode factor() { res = p Bindings ML Variable rocessIdenVfier(); ExprNode res; Variable Bindings ML break; switch(nextToken) { case LPAREN: Dan Grossman Dan Grossman getNextToken(); case INT: Fall 2011 Fall 2011 res = expr(); res = processIntConstant(); getNextToken();...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online