[SOLVED] CS451651 Project3- Parsing

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon project3-ghrfaj.zip (659.7 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (1 vote)
  1. Support long and double basic types.
  2. Support operators.
  3. Support conditional expression and switch statement.
  4. Support do-while and for statements.
  5. Support exception handlers.
  6. Support interface type declaration.

In this project, you will only be supporting the parsing of the above programming constructs and their representations in the abstract syntax tree (AST). To compile (just parse for now) your j– programs, you need to run the j– command as follows:

$ $j/j–/bin/j– -p P.java

which will only parse P.java and print the AST for the program in XML format.

Note.

  1. Consult appendix at the end for the grammar (ie, formal specification) for each new construct you will be supporting in j–.
  2. The AST output provided for each problem is meant to give you an idea as to what the AST ought to look like once the syntactic constructs for that problem are implemented in j–. You are expected to implement the writeToStdOut() method in the J* files for the constructs such that your AST output is something similar. The autograder will not match your AST against ours for correctness, but instead will test if your parser parses our pass tests without errors.

Problem 1. (Long and Double Basic Types) Add support for the long and double basic types.

$ $j/j–/bin/j– -p tests/BasicTypes.java

See tests/BasicTypes.ast for output.

Problem 2. (Operators) Add support for the following operators, obeying precedence rules (see appendix at the end).

~ != / /= -=
++ *= % %=
>> >>= >>> >>>= >=
<< <<= < ^ ^=
| |= || & &=

$ $j/j–/bin/j– -p tests/Operators.java

See tests/Operators.ast for output.

Problem 3. (Conditional Expression) Add support for conditional expression (e1 ? e2 : e3).

$ $j/j–bin/j– -p tests/ConditionalExpression.java

See tests/ConditionalExpression.ast for output.

Problem 4. (Switch Statement) Add support for a switch statement.

$ $j/j–/bin/j– -p tests/SwitchStatement.java

See tests/SwitchStatement.ast for output.

Problem 5. (Do-while Statement) Add support for a do-while statement.

$ $j/j–/bin/j– -p tests/DoWhileStatement.java

See tests/DoWhileStatement.ast for output.

Problem 6. (For Statement) Add support for a for statement.

$ $j/j–/bin/j– -p tests/ForStatement.java

See tests/ForStatement.ast for output.

Problem 7. (Exception Handlers) Add support for exception handling, which involves supporting the try, catch, finally, throw, and throws clauses.

$ $j/j–/bin/j– -p tests/ExceptionHandlers.java

See tests/ExceptionHandlers.ast for output.

Problem 8. (Interface Type Declaration) Implement support for interface declaration.

$ $j/j–/bin/j– -p tests/Interface.java

See tests/Interface.ast for output.

  • project3-ghrfaj.zip