Due Date: Saturday, March 16 at 11:59pm via GitHub.

Introduction

In this assignment your team will be augmenting the parser from A2 to generate an abstract syntax tree (AST), and then perform a full suite of semantic analysis checks against that tree. In the process you will also resolve all identifier uses with their corresponding definitions through a symbol table implementation.

A solution for the A2 parser.py has been provided in the accompanying starter code under parser_reference.py. You may build on this solution, or use your own work from A2.

High level requirements

  1. Modify the parser to generate AST using the provided AST class hierarchy:

    • You may wish to modify the AST at this stage in order to add source coordinates, for producing more helpful error messages.
  2. Implement all of the semantic analysis checks detailed in the Source language semantic analysis document:

    • This step should not directly interface with the parser, but rather work purely through the AST.
    • You are free to modify and extend the AST classes as you wish.
    • You should add new classes for keeping track of symbol table information.

Testing

Implement and document a strategy for testing your semantic analyzer. Consider developing a collection of "expected to pass" and "expected to fail" tests. In the case of failures, document how you expect them to fail.

Starter code package

Within your private team repository on GitHub, a a3starter branch has been pushed. Merge that branch into your master branch and follow the Getting started instructions in a3/README.md. See a3/AST.md for documentation on the provided AST class hierachy.

How to submit

Merge in the starter code and replace a3/csc488/parser/parser.py with either your A2 submission or with a3/csc488/parser/parser_reference.py. Implement AST generation, a semantic analyzer with symbol table, along with any associated tests.

You submission must run correctly on teach.cs.toronto.edu. Failure to correctly run in that environment may result in an overall assignment mark of 0.

Modify a3/README.md by adding the following:

Push your commits to the master branch of your repository prior to the deadline. Whatever is the most recent commit as of the assignment deadline will be considered to be your teams' submission for the assignment. The master branch will be checked again 24, 48 and 72 hours after the deadline if you choose to submit late and use grace days. If you are using grace day(s), be sure to update the README file to reflect how many.

Submission checklist