Suppose we wish to add a 'select statement to Core as follows: a select statement has the structure select bi -> si 11 b2 -> S2 || ... || bn -> Sn end; where bi, ..., bn are boolean expressions (i.e. (cond)'s), and si, ..., Sn are (stmt seqy's; and the number of b's is equal to the number of s's. We execute the select as follows: if bl evaluates to true, execute S1 and you are done; if b1 evaluates to false, and b2 to true, execute S2 and you are done; ...; if bi, ..., b(n-1) evaluate to false and bn to true, execute Sn; if bi, ..., bn all evaluate to false, simply go to the next statement that follows the select (i.e., the select, in this case, is a 'no-op'). Note that the "II" is a new terminal symbol that is used to separate each (cond), stmt seq) pair from the next pair. Now for the problems: 1. (8 points). Add the select statement to Core by modifying the BNF grammar appropriately. (Use "pure BNF", i.e., what we have been using in class. If you were to use "extended BNF, answering the next question will be much harder.) 2. (12 points). Using the notation from the class notes (copies of slides), write down the Execute-select- statement procedure and any other procedures you need to add to Core's interpreter to implement the select statement. Don't worry about the Parse-select-statement procedure. You may assume the array representation of the parse tree when answering this question. You may also assume procedures such as Execute-stm-seq or functions like Eval-Cond etc, already exist. Important Note: The problem is not asking you to show how you can achieve the effect of the select statement by using multiple if statements or anything like that. You are being asked to introduce a new statement into the CORE language so that the CORE programmer can write, as part of his or her CORE program, statements such as: select (x > 0) -> Y = 10; 11 (x > 0) -> X = 10; end; Suppose we wish to add a 'select statement to Core as follows: a select statement has the structure select bi -> si 11 b2 -> S2 || ... || bn -> Sn end; where bi, ..., bn are boolean expressions (i.e. (cond)'s), and si, ..., Sn are (stmt seqy's; and the number of b's is equal to the number of s's. We execute the select as follows: if bl evaluates to true, execute S1 and you are done; if b1 evaluates to false, and b2 to true, execute S2 and you are done; ...; if bi, ..., b(n-1) evaluate to false and bn to true, execute Sn; if bi, ..., bn all evaluate to false, simply go to the next statement that follows the select (i.e., the select, in this case, is a 'no-op'). Note that the "II" is a new terminal symbol that is used to separate each (cond), stmt seq) pair from the next pair. Now for the problems: 1. (8 points). Add the select statement to Core by modifying the BNF grammar appropriately. (Use "pure BNF", i.e., what we have been using in class. If you were to use "extended BNF, answering the next question will be much harder.) 2. (12 points). Using the notation from the class notes (copies of slides), write down the Execute-select- statement procedure and any other procedures you need to add to Core's interpreter to implement the select statement. Don't worry about the Parse-select-statement procedure. You may assume the array representation of the parse tree when answering this question. You may also assume procedures such as Execute-stm-seq or functions like Eval-Cond etc, already exist. Important Note: The problem is not asking you to show how you can achieve the effect of the select statement by using multiple if statements or anything like that. You are being asked to introduce a new statement into the CORE language so that the CORE programmer can write, as part of his or her CORE program, statements such as: select (x > 0) -> Y = 10; 11 (x > 0) -> X = 10; end