Docsity

CIS 400 Spring 2008 Programming Project: Part 3 - Semantic Analysis and Typechecking, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
CIS 400 Spring 2008
Programming Project, Part 3: Semantic Analysis
The third part of the programming project is to implement symbol tables and
typechecking for the Decaf language.
These typechecking and semantic rules are described in the document
DecafSemanticChecks.3.04.08.doc, from the design discussion held in class on Tuesday,
March 4. However, you may ignore all the semantic rules other than typechecking, i.e.
you do not have to check that there is a class “main” and that the statements for break,
continue and return follow their context guidelines.
On this web page are program templates to help you start programming this part of the
project. Here are the classes:
Semantics.java – contains a method “check” that you need to complete.
SymbolTable.java – contains the outline of symbol table structure and methods
for changing scope, inserting identifiers and finding identifiers for you to
complete.
Stentry.java – a data class to hold one symbol table entry
STtype.java – a data class to hold one type for an identifier
1. Complete the Symbol Table functions.
2. Go back through the recursive descent parsing functions and insert identifiers into the
symbol table whenever the declarations are processed.
3. Complete the check method in the Semantics class. This method will walk the
Abstract Syntax Tree produced by the parser and synthesize a type at each node. This
will include looking up identifiers in the symbol table and using the type information for
type checking. This method will be a recursive method that will synthesize types.
Due Dates:
By Tuesday, April 16, midnight, submit files to blackboard, zipped or not, as
convenient.
What to hand in:
Design and test document, can be named README, or some other obvious name,
describing design decisions and test results.
Program files, including code documentation.

Partial preview of the text

Download CIS 400 Spring 2008 Programming Project: Part 3 - Semantic Analysis and Typechecking and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

CIS 400 Spring 2008

Programming Project, Part 3: Semantic Analysis

The third part of the programming project is to implement symbol tables and typechecking for the Decaf language. These typechecking and semantic rules are described in the document DecafSemanticChecks.3.04.08.doc, from the design discussion held in class on Tuesday, March 4. However, you may ignore all the semantic rules other than typechecking, i.e. you do not have to check that there is a class “main” and that the statements for break, continue and return follow their context guidelines. On this web page are program templates to help you start programming this part of the project. Here are the classes: Semantics.java – contains a method “check” that you need to complete. SymbolTable.java – contains the outline of symbol table structure and methods for changing scope, inserting identifiers and finding identifiers for you to complete. Stentry.java – a data class to hold one symbol table entry STtype.java – a data class to hold one type for an identifier

  1. Complete the Symbol Table functions.
  2. Go back through the recursive descent parsing functions and insert identifiers into the symbol table whenever the declarations are processed.
  3. Complete the check method in the Semantics class. This method will walk the Abstract Syntax Tree produced by the parser and synthesize a type at each node. This will include looking up identifiers in the symbol table and using the type information for type checking. This method will be a recursive method that will synthesize types. Due Dates: By Tuesday, April 16, midnight, submit files to blackboard, zipped or not, as convenient. What to hand in: Design and test document, can be named README, or some other obvious name, describing design decisions and test results. Program files, including code documentation.