proj2 - COP4020 Programming Assignment 2 A CALC interpreter...

Info iconThis preview shows pages 1–2. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COP4020 Programming Assignment 2 A CALC interpreter Purpose: This project is intended to give you experience in using a parser generator(YACC), writing syntax specification (grammar) for a language, performing parsing and semantics analysis, and practicing error handling in a compiler. Project Summary: Your task is to write an interpreter for a simple calculator whose programming language, CALC , contains basic language constructs such as variables and assignment statements. The interpreter will be written using a compiler generator (YACC). The interpreter will call the lexical analyzer (lex) for the next token, parse the token stream, interpret the program statement-by-statement, and perform static and dynamic semantic checks, and print the results of the calculation in a program. Lexical specification: Table 1 list all tokens in CALC. The set of tokens is a subset of the tokens in PASC in Project 1. Table 1: Token numbers to be returned by yylex Token Symbolic name Token Symbolic name ; SEMInumber , COMMAnumber ( LPARENnumber ) RPARENnumber integer constant ICONSTnumber identifier IDnumber begin BEGINnumber end ENDnumber program PROGRAMnumber is ISnumber- MINUSnumber + PLUSnumber * TIMESnumber div DIVnumber var VARnumber print PRINTnumber end of file EOFnumber = EQnumber Syntax Specification: The syntax of the CALC language is described by a set of syntax diagrams in Figure 1. A syntax diagram is a directed graph with one entry and one exit. Each path through the graph defines an allowable sequence of symbols. For example, the structure of a valid CALC program is defined by the first syntax diagram. The occurrence of the name of another diagram such as declaration and compoundfirst syntax diagram....
View Full Document

This note was uploaded on 02/20/2012 for the course COP 4020 taught by Professor Engelen during the Spring '11 term at FSU.

Page1 / 3

proj2 - COP4020 Programming Assignment 2 A CALC interpreter...

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

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