CSC 330 Assignment 4

Assignment 4: Some Additional Information



The Use of Tokens in TreeNode IDs

The provided ejay.cup parser uses the following potentially non-obvious token IDs, for the indicated constructs:

ID Construct
SEMI Data Declaration
LEFT_BRKT Array Type (in type context)
LEFT_BRKT Array Selection Operation (in expression context)
LEFT_BRACE Struct Type (in type context)
LEFT_BRACE Block (in block context)
LEFT_PAREN Function Declaration
LEFT_PAREN Function Call as a statement
RT_PAREN Function Call in an expression
COMMA Formal Parameter Declaration

Note also the important difference between type keyword IDs versus literal type IDs. Here they are:

Type Keyword Literal Value
INT INTEGER
FLOAT FLOATING_PT
STRING STRING_LIT
BOOLEAN TRUE and FALSE

Refinements to the Specification of Error Handling

In conjunction with the Error Handling requirements specified in the original writeup, you must perform the following semantic checks:

  1. The variable on the LHS of an assignment statement must be defined, and it must designate a variable (as opposed to a function).
  2. The name of a function in a function call must be defined, and it must designate a function (as opposed to a variable).

The following are specific forms of error checking that you do NOT need to do:

  1. Type checking of function return values, i.e., that the type of expression in a return statement matches the declared return type of the function.
  2. Checking that a non-void function has at least one return, and that a void function has no return.

Some Specific Test Programs for the Phased Implementation

The following sample programs are recommended test cases for the different development phases in Assignment 4. They are simple enough to help you focus on particular aspects of the problem, one step at a time. As in the preceding assignments, the actual test data may include some test cases that are not specifically covered in these examples, so you are encouraged to expand on these examples to provide further test data of your own.