Select Page

CUNY John Jay College Java Code to Compile AST Node Paper

Question Description

You will submit your existing files (Parser.java, Node.java, IntegerNode.java, FloatNode.java, MathOpNode.java,Basic.java, Token.java, Lexer.java, VariableNode.java, PrintNode.java, AssignmentNode.java, StatementNode.java, StatementsNode.java) and your new files: StringNode.java, DataNode.java, ReadNode.java, InputNode.java.

One thing that we have not handled yet is constant strings. Add strings (a double quote, then any character that is NOT a double quote, then finally a double quote) to your lexer with a TOKEN TYPE of STRING. Create a AST node for a string following the same rules as always; call it StringNode.

Add STRING as something that can go into a printList.

There is a general pattern you will start to notice for adding a new statement type:

Create a new AST Node, following all of the usual rules (constructors, private members, ToString() and accessors).

Add the keyword to the lexer

Add a method in the parser to parse the token(s), creating the AST node

Add the method to statement()

Create new nodes for the READ and DATA statements (deriving from StatementNode). READ takes a list of variables. DATA takes a list of STRING, IntegerNode and FloatNode. Use a pattern like we did for PRINT to implement these.

Parse INPUT (another subclass of StatementNode). Notice that the first “parameter” to INPUT is EITHER a constant string or a variable. Don’t worry about checking the variable type for now. Input will also have a list of parameters, all variables.

"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you "A" results."

Order Solution Now