CMSC 431- Assignment 1

Summer 2004


Assignment 1

For programming Assignment 1 Part 1 you need to write recursive descent parser / evaluator for the following grammar:

 

A  -> VARIABLE "=" A | E | EVAL VARIABLE
E  ->  “+”  E T   |    “-'” E T     |     T
T  ->  “*”  T F  |    "/" T F      |     F
F->   EXP “(“ F G “)”               |     G
G  -> VARIABLE    | DOUBLE    |  “(“  E “)“    |   [ INVERSE] TRIG “(“   E “)“  
                            |  rads “(“ E “)”  | 
TRIG -> “cos'”| “sin'”| "tan"
INVERSE ->  “arc”
EVAL -> “eval”
 

 

 

 

Assignment 2

Repeat assignment using javacc  for the parser and lexer.


What You Should Hand In (and when)


  1. Your program - Assignments 1and 2 (h/c)
    1. should be well documented
    2. should include comments at the top that give the EBNF and a brief explanation of the technique
  2. A sample run of your program generated from my input  (h/c)
  3. In addition to the hardcopy to be turned in for this first project you need to mail me the following as attachments
      1. Your source code file(s) as a jar file
      2. A README file that explains how to build and run the executable 

Notes


Implementation Details

  1. Your implementation must be in Java and use JLex and javacc 

Input data

Sample data will be posted the week of  26 July.

( Note that there can be more than one expression per line and more than one line per expression, tokens don't span lines.

 

Due Dates, etc

  1. Due Dates- see above
  2. You may work in group of up to two.
  1. NO LATE PROGRAMS WILL BE ACCEPTED under any circumstance without written approval.
  2.  Any student caught cheating will receive a zero!

 

If you have any questions mail me.