CS 325 Project Part IV
In the last phase of the project, you will be cleaning up your compiler in order to make it functional and user friendly. This involves modifying your compiler to generate a listing file, creating batch files to assemble the output of your compiler, and run the output of your compiler.
Listing
Your compiler should list out error messages to stderr using System.err.println. Any error message should contain the line number where it was first detected. Specifically, error messages should be of the form <lineNo> : <errorString>
Try to make your error messages descriptive enough so that you as a SIMPL programmer would find them useful for debugging.
Rather than compiling I/O operations straight into assembly code, I/O operations are assembled into calls to I/O routines. The I/O routines are in the file IO.zip which may be downloaded from the course web-site.
The major procedures are:
registerIO(name) creates the I/O window and displays the program name
inputNum(name) prompts with a variable name and waits for integer input
inputLog(name) prompts with a variable name and waits for boolean input
outputNum() prints out the output variable integer value.
outputLog() prints out the output variable boolean value.
Your compiler should allow you to specify the source file on
the command line. The compiler must
assign the run time arguments <filename>.sim ,
<filename>.j, and <filename>.lst to stdin, stout, and sterr as
follows:
try {
in = new PushbackInputStream(new FileInputStream(args[0]+.sim));
System.setOut(new PrintStream(new
FileOutputStream(args[0]+.j));
System.setErr(new PrintStream(new
FileOutputStream(args[0]+.lst));
} catch (IOException e) {System.err.println(I/O error);}
You need to create a batch file to run your compiler and another batch file to run the compiled program.
Your file simpl.bat should look something like:
@echo
off
set
PATH=%PATH;<path of simpl class
files>;c:\jasmin\bin;c:\j2sdk1.4.2_07\bin
set
CLASSPATH=<path of I/O files>;.
c:\j2sdk1.4.2_07\bin\java
simpl %1 %2 %3 %4 %5 %6 %7 %8 %9
c:\jasmin\bin\jasmin
%1.j %2 %3 %4 %5 %6 %7 %8 %9
Be sure to check for the actual paths on the system you are
using.
Your
file run.bat should look something like:
@echo
off
if "%1"=="" goto usage
if not "%2"=="" goto usage
set CLASSPATH=<path of I/O files>;.
c:\j2sdk1.4.2_07\bin\java %1
goto end
:usage
echo Usage: run "progname"
:end
Errview is a program that allows you to view error messages through a graphical interface. To run errview, use the command java errview source errList, where source is the file name of the source file, including the extension, and errList is the name of the file containing the error messages. Errview will display a window containing a source code section, and an error list. Double clicking on a particular error message will highlight the appropriate source line. You will want to add the proper commands to your simpl.bat file so that your error messages are displayed.
I want you to demonstrate your project to me upon completion. You must show me the execution of working SIMPL programs as well has programs that produce error messages.
Modify your parser so that instead of aborting on an error message it uses error recovery.