Question: For this exercise you will write a parser using a parser generator . You will describe the Cool grammar in an appropriate input format and
For this exercise you will write a parser using a parser generator. You will describe the Cool grammar in an appropriate input format and the parser generator will generate actual code (in OCaml). You will also write additional code to unserialize the tokens produced by the lexer stage and to serialize the abstract syntax tree produced by your parser.

using the cool syntax figure above translate the following javascript syntax into OCaml and name the OCaml file parser.mly


example of some of the translation is shown below here.

Cool Syntax program class feature [class;]+ class TYPE inherits TYPE] { [feature;]* } ID(( formal [, formal]']): TYPE { expr} ID : TYPE ( expr ; ]' esac new TYPE isvoid expr expr + expr expr - expr expr * expr expr / expr expr expr CASE ELSE ESAC FI IF IN LET LOOP OF POOL THEN WHILE token
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
