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.

Task 2: 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 3: Example program

In the process of writing your interpreter, you should have a complete example program in your language, which is totally different from the provided one, and which shows off all the features and syntax things available in the language, including escape codes, nested expressions, comments, reversals, concatenations, inputs, and literals.

You need to turn in that example program (or write it now if you didn’t already), along with some sample correct input/output pairs that could be used to test it.

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: