Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a top-down parser in java accepting the (left-recursing free) language below. To simplify matters, assume the input to your parser is a list (=string)
Write a top-down parser in java accepting the (left-recursing free) language below. To simplify matters, assume the input to your parser is a list (=string) of tokens, for example as follows:
E ::= -E | 0E' | 1E' | 2E' | ... E' ::= +E | *E | /E |
interface Token class T_Plus () implements Token class T_Times () implements Token class T_Minus () implements Token class T_Division () implements Token class T_Int ( n : Int ) implements Token
Here is a suggestion for the data type of abstract syntax trees in pseudo-code.
interface AST class Plus ( l : AST, r : AST ) implements AST class Times ( l : AST, r : AST ) implements AST class Minus ( arg : AST ) implements AST class Div ( l : AST, r : AST ) implements AST class Integer ( n : Int ) implements AST
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started