Grades and deadlines

Getting started: files

Make a new directory for this lab.

Download the file lab1.2.yml into that directory.

As you complete your work for this part, you will fill in and eventually submit this file.

You will be programming in java and submitting java source code. Start by making an empty java file Interp.java with a main method.

Task 1: Choose a language

Here are specs for the winning languages invented by your classmates in last week’s lab. During lab, your section leader will run a “draft” to decide who works on what language.

Take note of who is working on the same language as you! This applies across all sections of SI413:

Task 2: Example program

Read the specs for your chosen language carefully! You will start by writing an example program in this language.

The requirements are the same as last week, except that (most likely) you didn’t design this language yourself! Ultimately you should be able to use this program to test your complete interpreter, but more importantly, writing this example program will help you actually understand how the language is supposed to work.

If you did a great job last week and the language you are working on is the one you designed, your reward is that you can re-use the same example program that you already wrote from last week’s lab!

REQUIREMENTS

Fill in the complete source code (along with comments) under the example_program field in spec.yml

Come up with at least two input/output test cases, representing sample input that could be entered at the console when your program is run, and the expected output that would be printed by your program as a result.

Fill these in under example_input_1, example_output_1, etc.

Your example program must:

Task 3: Writing your interpreter

Write a complete, working interpreter for your programming language, in Java. Your main method in Interp.java should take one command-line argument, which is a filename of a program in your language, and then execute the code in that program.

REQUIREMENTS

Submit all the java source code required to compile and run your interpreter.

I will run your code like this:

javac *.java
java Interp some_file.txt

where some_file.txt is source code for your chosen language.

Your interpreter should only run the program specified and not print out anything else to standard out. If you want to have a nice “welcome” message or prompt strings, etc., be sure to print those to System.err only.

For credit on this lab, your interpreter must work on any valid program in your chosen language.

If your interpreter identifies an error in the input program, call System.exit(7); to indicate that your interpreter correctly identified the error and didn’t just crash. In this case, it doesn’t matter what your program prints; the only requirement is that it exists with that exit code.

Tips

This is a tough assignment, but you can do it! Here’s how I would proceed:

Task 4: Peer testing

Peer testing is very straightforward this week: When you are testing someone’s interpreter, you mostly just need to run it on your big, complete example. If everything works, give your classmate a high five.

As with last week, everyone needs to act as the final reviewer for a classmate who is writing an interpreter for the same language. Ask your section leader for help if you don’t remember who is working on the same language as you.

REQUIREMENTS

Fill in the following fields in your spec.yml: