Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!