Cup lecture 1 lecture 1 course course mechanics by

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: ken(Token.LPAREN); getch();! return result; ! case ‘)': result = new Token(Token.RPAREN); getch();! return result;! case ‘;': result = new Token(Token.SCOLON); getch();! return result;! // Repeat for other single character tokens…! Winter 2013 UW CSE 401 (Michael Ringenburg) 32 16 1/14/13 getToken() (2) CSE341: Programming CSE341: Programming Languages Languages case '!': // ! or !=! getch();! Lecture 1 Lecture 1 if (nextch == '=') {! C Token.NEQ result = newMechanics Mechanics Course Token(ourse ); getch(); ! return result;! ML Variable Bindings } elseL{Variable Bindings M! result = new Token(Token.NOT); return result;! }! Dan Grossman !! Dan Grossman case '<': // < or <=! Fall 2011 Fall 2011 getch();! if (nextch == '=') {! result = new Token(Token.LEQ); getch();! return result;! } else {! result = new Token(Token.LESS); return result;! }! ! Winter 2013 UW CSE 401 (Michael Ringenburg) 33 getToken() (3) CSE341: Programming CSE341: Programming Languages Languages case '0': case '1': case '2': case '3': case '4': ! case '5': case ecture 1 Lecture 1 L '6': case '7': case '8': case '9': ! // integer constant! ourse Mechanics C String Cum = nextch;! n ourse Mechanics ML Variable Bindings ML getch();!Variable Bindings while (Character.isdigit(nextch)) {! num = num an Grossman Dan Grossman D + nextch;! Fall 2011 getch();! Fall 2011 }! result = new Token(Token.INT,! Integer(num).intValue());! retur...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online