The question involves two parts and is for a compiler design course. See the image below for the question. It may help if you have used a tool called ANTLR and know about grammar files. Answer part 1...
Part 1: In BDL (badly designed language), the equal sign is the assignment operator. The language allows multiple assignments such as i -j k which first assigns the value of variable k to variable j, and then the variable i to variable i. The following is from the ANTLR 4 grammar BDLg4: (1) grammar BDL; (2) program: stmtist (3) stmtlist stmt stmt; (4) stmt: asgn l; (5) asgn (6) source (7) expr: var; (8) ar: ID (9) ID: a-zA-ZI][a-zA-ZO-9; (10) WS:Iltn+-> skip; Complete the right sides of the rules for asgn (line 5) and source (line 6) Part 2: In BDL, the equal sign is also the comparison operator. (Yes this is based on an actual programming language.) A comparison is surrounded by parentheses, For example, in the statement j- (j k) the value of i is set to either true or false, depending on whether j is equal or not equal to k. Modify the grammar of Part 1 to support the comparison operator. Hint. You need to replace line 7 witlh one or more new rules
Part 1: In BDL (badly designed language), the equal sign is the assignment operator. The language allows multiple assignments such as i -j k which first assigns the value of variable k to variable j, and then the variable i to variable i. The following is from the ANTLR 4 grammar BDLg4: (1) grammar BDL; (2) program: stmtist (3) stmtlist stmt stmt; (4) stmt: asgn l; (5) asgn (6) source (7) expr: var; (8) ar: ID (9) ID: a-zA-ZI][a-zA-ZO-9; (10) WS:Iltn+-> skip; Complete the right sides of the rules for asgn (line 5) and source (line 6) Part 2: In BDL, the equal sign is also the comparison operator. (Yes this is based on an actual programming language.) A comparison is surrounded by parentheses, For example, in the statement j- (j k) the value of i is set to either true or false, depending on whether j is equal or not equal to k. Modify the grammar of Part 1 to support the comparison operator. Hint. You need to replace line 7 witlh one or more new rules