{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CSE340Fall2009Project1

CSE340Fall2009Project1 - Arizona State University Computer...

Info icon This 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
Image of page 1

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

View Full Document Right 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 iii.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern