CPS710

Assignment 3

Ryerson University

Interpreter

Due: December 18


Objectives

In this assignment you will writing a complete interpreter for HL except that it will not handle errors in programs.

This should familiarize you with symbol table manipulation, semantic analysis, and evaluation.

Step 1 - Parser preparation

A parser solution will not be provided for this assignment, but you will need a functional parser to proceed. You may now collabrate with your classmates to make sure that your parser in functional.

This assignment can be done in teams of 2 people at no penalty. If you are going to work in a team you should decide which parser you are going to work from. You can combine your parsers if you wish. You can now also copy parser code from classmates if you wish.

Once you have a functional parser, here are some additional changes/decisions you will need to make about your parsing:

  1. Add the println function as defined in the built-in functions to the HL grammar and to your parser.

  2. Decide whether you want to define the other three built-in functions in the grammar as was done for the printing functions, or as special cases of function calls. If you decide to integrate them in the grammar, then you should allow expressions as parameters.

  3. You may also want to rework the HL grammar a little to implement some of the semantics of HL. In particular, you can probably remove stop and return statements from the top level statements. However, this is not absolutely necessary, and you can deal with this issue later on in your error handler instead.

Step 2 - Preparation

Before you start writing your evaluator code, you need to set up your project to facilitate this process with jjtree. The facilities offered by jjtree are explained in Handout 5-5 Visitors
  1. Make a new copy of your second assignment and replace TestHL.java and SimpleNode.java by the ones here.

  2. Add the option
    VISITOR_EXCEPTION="Exception";
    to HL.jjt

  3. Compile your project and use the createEval script to create a file Eval.java from the interface HLVisitor.java. The instructions on how to use this script can be found in the EXPLANATION file of the Scripts directory. The file Eval.java is the main file for this assignment. It will now contain one evaluator visitor for each type of syntax tree.

Step 3 - Assignment

Write an interpreter for the language HL, which is a special-purpose language for the manipulation of polynomials. Here are detailed semantic specifications for HL:

Advice

References

Supporting Files

Testing information

Here are the steps we will take to test and grade your assignment:
  1. We will provide 3 default files in case you did not:
  2. We will download and open your A3.zip submission and run either your makefile on it or ours if you did not provide a replacement.
  3. We will then run all the tests specified in the marking sheet in the order in the marking sheet and compare them with the results files.
  4. scoping.hl determines whether you implemented static or dynamic scoping. We have an alterate test file to do this in case your program crash with scoping.hl: scopetype.hl.

How to submit the assignment


This page is maintained by Sophie Quigley (cps710@scs.ryerson.ca)
Last modified Saturday, 17-Dec-2016 00:39:21 EST