CSE340Fall2009Project1

CSE340Fall2009Project1 - Arizona State University Computer...

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

View Full Document Right Arrow Icon
Arizona State University Computer Science and Engineering CSE 340 Fall 2009 Programming Assignment #1 Instructor: Rida Bazzi DUE: October 27 2009 The goal of this project is to give you some hands-on experience with recursive descent parsing and symbol tables. You will write a basic type checker for a simple language whose specification follows. After the specification of the language, I list the requirements for type checking. I start by giving an example program B1: BEGIN TYPE A: integer; B, C: Boolean VAR a : A; b, c : B; d : C; ASSIGN b = c; a = d; b = c/d; B2: BEGIN TYPE A : boolean; B : inetegr; VAR a : A; b, c : B; d : real; ASSIGN b = c; a = d; B1.a = a; END b = c/d; B3: BEGIN TYPE A : real; B : ; VAR a : A; b, c : B; d : real; ASSIGN b = c/d; a = d; d = B2.d; END END
Background image of page 1

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

View Full DocumentRight Arrow Icon
BLOCKS A block consists of three optional parts 1. Type declaration: new names for types are introduced suing basic types. The basic types are int , real , char , and Boolean. Types names are single characters. They are declared in a comma separated list of type names followed by a column followed by a type name, which can be a previously declared type name or a basic type. If the right hand side of a type declaration is a name that has not been previously declared, there is an undeclared type name error . 2. Variable Declaration: variable names are single characters. They are declared in a comma separated list of variables followed by a column which is followed by a type name 3. Assignment section: this section contains assignments. It can also contain other blocks. There is no limit on the level of nesting of blocks that is allowed. The assignments are of one of two forms: a. Simple assignements: these are of the form a = b where a and b are variable names or variable accesses (more about that later). These names should have been previously declared otherwise there is an undeclared variable error . If the name has been previously declared as a type, there is a type name used for variable name error . Assignments have the following restrictions i. Variables of the same types can always be assigned to each other ii. Boolean variables can be assigned to integer or real variables
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/27/2011 for the course CSE 340 taught by Professor Farley,t during the Fall '08 term at ASU.

Page1 / 6

CSE340Fall2009Project1 - Arizona State University Computer...

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

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