CS 327 Homework 3

Due Date
4:00 pm Friday September 25
Assignment Names
hw3
File Names
ast.c error.c list.c pool.c sc.c testlexer.c codegen.c lexer.c parser.c reserved.c testparser.c ast.h codegen.h debug.h error.h lexer.h list.h parser.h pool.h reserved.h Makefile
Copy the files from /home/mathcs/courses/cs327/stack. Make the following modifications to the lexical analyzer and parser.
  1. Add the relational operators < <= > >=
  2. Add the binary operators LT LE GT GE
  3. Make the write and writeln statements take multiple arguments, like this: write(1, a + 2, 3)
  4. In addition, modify write and writeln to allow (but not require) field widths for arguments, like this: write(1 : 10, a + 2, 3 : w + 4). You will need to modify the lexer, parser, and ast.
  5. Add a repeat statement. The syntax is repeat stmt_list until rel_expr. You will need to modify the lexer and parser and add a case in the ast.
  6. Add (or modify existing) print functions for the ast additions. Use the same style as the original print functions.

Turnin will create and collect a tar ball containing your files, in addition to running testlexer and testparser on some sample files. If you don't fix up the print functions then I will be unable to test your additions, so don't ignore this part of the assignment.