CPS710

Assignment 1

Toronto Metropolitan University University

Scanner

Due: October 2


Objectives

In this course you will be developing an interpreter for a high-level language, called HL, which manipulates lists and strings.

In this assignment you will be using JavaCC to build HL's scanner. This should familiarize you with the use of lexer generators and the scanning process.

The learning objectives addressed in this assignment are 2Cc (which includes 2De), 2Ba, and 2Aa.

Preparation

Before you start your assignment, you will need to set up the environment under which you will be working. You can develop your assignment on whatever platform you prefer. However, we will only test it on the moons, so you should verify your work on this platform before submitting it to make that no technical problems will interfere with the assessment of your work.

Here is how you should prepare your environment on the moons:

  1. Create a directory where you will do your work, with a subdirectory called Tests.

  2. Copy all the files in the Handouts directory into your working directory. These files are located on the moons at ~cps710/public_html/doc/F2024/A1/Handouts and you can copy them into your current directory with the command:
    cp ~cps710/public_html/doc/F2024/A1/Handouts/* .
    cp ~cps710/public_html/doc/F2024/A1/Handouts/src/* .
    
    Here are the files:

  3. Make the two testing scripts t and runtests executable by giving them user x perms. This is done with the command:
    chmod u+x t runtests

  4. Get rid of the two TestHL source files that you will not need at first (you will be left with TestHL.java which is a copy of TestHLC.java):
    rm TestHLC.java
    rm TestHLB.java
    

  5. Compile everything once to make sure that your compilation settings are correct. This is done with the command:
    make
    This will also generate additional files that you can modify later.

  6. Test that your program is running properly by typing
    java -classpath . TestHL
    and typing the strings "else" and "for".
Your development and testing environment on the moons is now ready. If you wish to develop your program in a different environment, you will need to also do something similar for that environment.

Assignment

Once you have set up the environment, and verified that it runs smoothly, you can start your assignment.

If you are planning to implement the B learning objectives in this assignment, then you will need to replace TestHL.java by TestHLB.java after you have implemented STRING tokens:

cp ~cps710/public_html/doc/F2024/A1/Handouts/src/TestHLB.java ./TestHL.java

Testing your Assignment

As described in the preparation section, there are two possible TestHL programs for your assignment: TestHLC.java which will be used to test submissions which only implement the C learning objective, and TestHLB.java which will be used to test all other submissions. To run your own tests, be sure to copy the appropriate one for your situation and rename it TestHL.java.

The testing files used to test your submissions are in the Tests directory. If you are doing your testing only on the moons, you do not need to copy these files because the test scripts access them directly. However, if you need to copy them for any reason, the direct path on the moons of the Tests directory where you can retrieve them from is ~cps710/public_html/doc/F2024/A1/Tests

The test files have prefixes describing the learning objective tested. Some learning objectives are tested with multiple files. You can see the order in which the tests are run in runtests.

Each test consists of two files, an .hl file for the input, and a corresponding .expected file for the expected output against which your output will be compared using the testing scripts:

Submitting your Assignment

The name of the file that you submit will indicate to us which learning objectives to test, so please follow the directions below carefully.

Once you have verified that your source does compile and run properly on the moons:

References


This page is maintained by Sophie Quigley (cps710@cs.torontomu.ca)
Last modified Wednesday, 25-Sep-2024 11:14:09 EDT