CS403: Programming Languages

Recognizer/Parser Module

Version 1
Printable Version

Building a recognizer

This is your third module for your Designer Programming Language assignment. You may develop your code using any of the allowed procedural language, but you must ensure it runs correctly under Linux before submission.

Your task is to write a recognizer for your language. A recognizer is like a souped-up scanner; additionally, it determines whether or not the lexemes are in the proper order. One builds a recognizer by implementing a grammar.

Recursive Descent Parsing

Once you have developed a grammar for your language, the next task is to build a recognizer for your language via recursive descent parsing. A recognizer is a program which says whether the expressions (sentences) in your source code are syntactically legal. A parser is an implementation of a grammar. A recursive descent parser is a parser composed of a set of parsing functions, each of which derives from a rule in the grammar. It should become apparent why the appellation recursive descent is used to describe parsers built in this fashion. Begin by reading this.

Coding Standards

Coding standards are as before.

Specifics

Specifically, you are to write a recognizer for your language. You should complete your grammar implement an appropriate recognizer. One should be able to run the recognizer on a file consisting of a single program by typing in the command:
    recognizer FFFF
where FFFF is the name of the file to be recognized. The output of the program should be the string "legal" or "illegal". In the case of an illegal expression, the error generated by match should be displayed prior to the output of the program. For testing purposes, have the match error be printed to stdout. The match error should include the line number where the error was detected.

You should supply a five test cases. A README file should specify which test cases result in which outputs. One should be able to run the tests with the makefile targets: test1, test2, test3, test4, and test5.

Submitting the assignment

To submit your assignment, delete all object or class files from your working directory, leaving only source code, a makefile, a README file, and any test cases you may have. Then, while in your working directory, type the command
  submit proglan lusth recognizer
The submit program will bundle up all the files in your current directory and ship them to me. This includes subdirectories as well since all the files in any subdirectories will also be shipped to me.

You may submit as many times as you want before the deadline; new submissions replace old submissions.

Make sure you that I will be able to call your recognizer with the command named recognizer. The command recognizer must take a filename as a command line argument.

You must supply a makefile that will compile your recognizer when responding to the commands make and make run. The make run command should test your implementation on your own test files. There should be at least one “good” test file and a few “bad” ones illustrating various syntax errors.