dis2 - CMPSC 160 Translation of Programming Languages...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMPSC 160 Translation of Programming Languages Project 1: Calculator Contd Calculator Review Scanner Read input string Identify tokens Lexical Analysis (DFA) Parser Syntax Analysis (LL(1)) Generate parse tree ParseTree Draw parse tree Calculator Recursive Function Consider the following grammar Expr + Term ExprP |- Term ExprP | void Expr() { parsetree.push(NT_Expr); parsetree.pop(); } Symbol First Follow Expr +, -, ), | Calculator Recursive Function Consider the following grammar Expr + Term ExprP |- Term ExprP | void Expr() { parsetree.push(NT_Expr); switch( scanner.next_token() ){ } parsetree.pop(); } Symbol First Follow Expr +, -, ), | Calculator Recursive Function Consider the following grammar Expr + Term ExprP |- Term ExprP | void Expr() { parsetree.push(NT_Expr); switch( scanner.next_token() ){ case T_plus: } parsetree.pop(); } Symbol First Follow Expr + , -, ), | Calculator Recursive Function Consider the following grammar Expr + Term ExprP |- Term ExprP | void Expr() { parsetree.push(NT_Expr); switch( scanner.next_token() ){ case T_plus: eat_token(T_plus); } parsetree.pop(); } Symbol First Follow Expr +, -, ), | Calculator Recursive Function Consider the following grammar Expr + Term ExprP |- Term ExprP | void Expr() { parsetree.push(NT_Expr); switch( scanner.next_token() ){ case T_plus: eat_token(T_plus); Term(); } parsetree.pop(); } Symbol First Follow Expr +, -, ), | Calculator Recursive Function Consider the following grammar Expr + Term ExprP |- Term ExprP | void Expr() { parsetree.push(NT_Expr); switch( scanner.next_token() ){ case T_plus: eat_token(T_plus); Term(); ExprP(); break; } parsetree.pop(); } Symbol First Follow Expr +, -, ), | Calculator Recursive Function Consider the following grammar Expr + Term ExprP |- Term ExprP | void Expr() { parsetree.push(NT_Expr); switch( scanner.next_token() ){ case T_plus: eat_token(T_plus); Term(); ExprP(); break; case T_minus: eat_token(T_minus); Term(); ExprP(); break; } parsetree.pop(); } Symbol First Follow Expr +, - , ), | Calculator Recursive Function Consider the following grammar Expr + Term ExprP |- Term ExprP | void Expr() { parsetree.push(NT_Expr);parsetree....
View Full Document

This note was uploaded on 11/23/2010 for the course MATH 104b taught by Professor Ceniceros,h during the Spring '08 term at UCSB.

Page1 / 40

dis2 - CMPSC 160 Translation of Programming Languages...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online