semant
Class SemanticAnalyzer

java.lang.Object
  extended by semant.SemanticAnalyzer

public class SemanticAnalyzer
extends java.lang.Object

The SemanticAnalyzer class performs semantic analysis. In particular this class is able to perform (via the analyze() method) the following tests and analyses: (1) legal inheritence hierarchy (all classes have existing parent, no cycles), (2) legal class member declaration, (3) there is a correct Main class and main() method, and (4) each class member is correctly typed. This class is incomplete and will need to be implemented by the student.


Constructor Summary
SemanticAnalyzer(Program program, boolean debug)
          SemanticAnalyzer constructor
 
Method Summary
 ClassTreeNode analyze()
          Analyze the AST checking for semantic errors and annotating the tree Also builds an auxiliary class hierarchy tree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SemanticAnalyzer

public SemanticAnalyzer(Program program,
                        boolean debug)
SemanticAnalyzer constructor

Parameters:
program - root of the AST
debug - boolean indicating whether debugging is enabled
Method Detail

analyze

public ClassTreeNode analyze()
Analyze the AST checking for semantic errors and annotating the tree Also builds an auxiliary class hierarchy tree

Returns:
root of the class hierarchy tree (needed for code generation) Must add code to do the following: 1 - build built-in class nodes in class hierarchy tree (already done) 2 - build and check the class hierarchy tree 3 - build the environment for each class (adding class members only) and check that members are declared properly 4 - check that the Main class and main method are declared properly 5 - type check each class member See the lab manual for more details on each of these steps.