Program 1: Lexical/Syntactical Analysis

ATTENTION! There were errors in three test files: exit1.9 -- ';' was missing after 'exit', if.1.9 -- ';' was missing after 'return', and write2.9 -- '"' was missing in one of the strings. These errors were corrected, but since it is possible that some people made an effort to make their program pass 'exit' and 'return' without ending ';', this syntax will be accepted for this assignment only. Tests are created by humans, and it is human to err, so if you see a discrepancy between EBNF and test, contact instructor or teaching assistant.

ATTENTION! Error messages. The tests directory contains examples of error messages. Make sure your output is identical to those. The output of your program will be compared to expected output using diff, and if it returns a nonzero value, your program fails that test. There are many tests which were not disclosed to you, and if your program fails them all, you will have a hard time proving that your program works just fine, but outputs a slightly different error message. I want to give you a fair grade, so pretty please, with sugar on top, check the format of your error messages and save your time (and mine). -- A.K.

Assignment:

Build a scanner and parser for ice9.

Description:

Each scanner inputs a source and outputs the lexical tokens found in the file. If there is a lexical error, a message is written to standard error and scanning is aborted.

The tokens from the scanner are parser. If the source program is syntactically correct, the compiler outputs nothing. On the other hand, when your compiler discovers a syntactical error it issues an error message and exits. It does not continue processing the input. The parser outputs an error message for the first (and only) error it discovers.

Resources:

Turnin:

Copy all your source files, including a Makefile, to your turnin directory by the specified time. Do not include binaries or object files.

Grading:

Testing uses a set of lex and parse files. Points are awarded if input is correctly scanned (20%) and parsed (80%). The test program files have different point values; no partial credit. Your program will be invoked with a command similar to the following:

ice9 file.9 >& file.out

It will then be compared to known correct output

diff file.out Out.file

Therefore, students must ensure that their program's output is identical to that expected.

Expected output consists of error messages only. Avoid printing extraneous messages as they can affect your grade. All messages have format:

filename: lineno: errormessage
where filename is the name of the input file, lineno is the line on which the error was detected, and errormessage is the error message. Error message from scanner can be
unterminated string
or
Illegal character (c)
where c is the illegal character. Error message from parser can be
syntax error near YYTEXT
where YYTEXT is the text corresponding to the token which causes the error. See some examples in the test directory. No more errors can be detected at this point.


vin@nd.edu
Last modified: Sun Feb 3 19:00:51 EST 2002