Question: Language : C++ Build a recursive descent parser for MYC language. The grammar should not be that complex than a few rules, as the only

Language : C++

Build a recursive descent parser for MYC language. The grammar should not be that complex than a few rules, as the only two types of statement in this language will be declaration statements and assignment statements. You will now take the tokens generated by your scanner (build a scanner first) and using recursive descent parse to determine if they represent a syntactically valid program. A program in MYC has the following format:

PROGRAM declarations BEGIN statements END; There can be any number of variable declarations and they have the following format: type variable; where type is either INTEGER or REAL and a variable is only one variable has to follow the format that we considered in our scanner. There can be any number of statements with each statement followed by a semicolon. There is only one type of statements: assignments. Its general form is: variable := math_expression; Math expressions can have either of the following forms: operand binary_op operand operand where the possible binary_op could be any of the following: '+', '-', '*', and '/'. An operand can be either a variable or a number. Note that expressions are prioritized as the following: expressions between parentheses, * and /, and then + and -, all from left to right associativity. Here is a sample program in MYC: PROGRAM INTEGER A; REAL B; BEGIN B := 2.3; B := B * 5.0; A := 10; A := A * (B * 10); END;

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!