treeNodes
Class Program

java.lang.Object
  extended by generalHelpers.TreeNode
      extended by treeNodes.Program

public class Program
extends TreeNode

Defines AST constructor 'program'.

See TreeNode for full documentation.


Field Summary
protected  ListNode<Class_> classes
           
 
Fields inherited from class generalHelpers.TreeNode
lineNumber
 
Constructor Summary
Program(int lineNumber, ListNode<Class_> a1)
          Creates "program" AST node.
 
Method Summary
 void cgen(java.io.PrintWriter s)
          This is the entry method for the code generation.
 TreeNode copy()
          Creates a copy of this node.
 void dump(java.io.Writer out, int n)
          Pretty-prints this node to this output stream.
 void dumpWithTypes(java.io.Writer out, int n)
           
 ListNode<Class_> getClasses()
           
 void semant()
          This method is the entry point to the semantic checker.
 
Methods inherited from class generalHelpers.TreeNode
copyAbstractSymbol, copyBoolean, dumpAbstractSymbol, dumpBoolean, dumpLine, getLineNumber, set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classes

protected ListNode<Class_> classes
Constructor Detail

Program

public Program(int lineNumber,
               ListNode<Class_> a1)
Creates "program" AST node.

Parameters:
lineNumber - the line in the source file from which this node came.
a0 - initial value for classes
Method Detail

getClasses

public ListNode<Class_> getClasses()

copy

public TreeNode copy()
Description copied from class: TreeNode
Creates a copy of this node.

Specified by:
copy in class TreeNode
Returns:
a copy of this node

dump

public void dump(java.io.Writer out,
                 int n)
          throws java.io.IOException
Description copied from class: TreeNode
Pretty-prints this node to this output stream.

Specified by:
dump in class TreeNode
Parameters:
out - the output stream
n - the number of spaces to indent the output
Throws:
java.io.IOException

dumpWithTypes

public void dumpWithTypes(java.io.Writer out,
                          int n)
                   throws java.io.IOException
Throws:
java.io.IOException

semant

public void semant()
            throws SemanticError
This method is the entry point to the semantic checker. You will need to complete it in programming assignment 4.

Your checker should do the following two things:

  1. Check that the program is semantically correct
  2. Decorate the abstract syntax tree with type information by setting the type field in each Expression node. (see the class AbstractExpression)

You are free to first do (1) and make sure you catch all semantic errors. Part (2) can be done in a second stage when you want to test the complete compiler.

Throws:
SemanticError - to signal error in semantic checking

cgen

public void cgen(java.io.PrintWriter s)
This is the entry method for the code generation.

Parameters:
s - -- writer to write the generated code to