Projects:

Project 1: RPal Parser

Remember:

Goals:

The objective of this first project is to implement a lexical analyzer, and a recursive descent parser for the RPAL language. The grammar for RPAL appears in your class notes.

You must write your OWN lexical and syntax analyzers in the language of your choice (C/C++/Objective C, Java, Haskell, Brainf***, Rpal). If you want to use something other than the C family or Java, discuss it with the TA first. You are NOT allowed to use 'lex' and 'yacc' or any similar software in order to implement this project.

For lexical analysis, a brief description will be made in class. There are many good textbooks that describe how to construct them. In essence, a lexical analyzer is a Finite-State Automaton. The lexcial rules for RPAL appear in the class notes.

The syntax for the RPAL language is defined in the language notes.

Regarding grading and submission

  1. Put in a BUGS file all comments of known errors (if any) of your project. It is MUCH better for you to list the limitations of your software than to let us discover them. The more time it takes for us to find what's wrong with your program, the larger the portion of credit WE (and not you) earn. In short, you must make it easy for us to examine your program.
  2. Your output should match the corresponding tree for each one of the test programs. Please bear with the idiosyncracies of my parser, and match its behavior anyway.
  3. Grading strategy: To grade your project, we will run your program on each of the test programs, and we will compare (bit by bit, electronically, of course) your AST with the correct one. Full credit will be given a perfect match in every case. Credit will be lost for failing to follow the above instructions. Readability and clarity of the source code is also important for your grade.
  4. Executable Name: p1. Include a make file in your submission.

    You must provide a makefile to build this project. We will compile your program by invoking: make

    we will then test p1 by invoking it as follows:

    p1 testprog1

    p1 testprog2

    ..

    Notice that the input is NOT standard input (stdin), but instead a command-line parameter.

    Examples:

    p1 -debug /cis/homes/manuel/systems/pal/tests.rpal/trees

    p1 -ast /cis/homes/manuel/systems/pal/tests.rpal/Treepicture

  5. p1 (without switches) should produce no output whatsoever.

    Required switches: -ast This switch prints the abstract syntax tree, and nothing else. No headers or footers. The AST must match exactly, character for character, the AST produced by rpal.

    Optional switches: -l This produces a listing of the input.

  6. It must be possible to run p1 from ANY directory: ~user/cop5555/p1 testfile

     

 

Electronically submit a single zip file by CourseWork. The deadline for this homework is TBA at midnight. Make sure you submit before TBA. Any questions about the homework or CourseWorX, email any TA.