Question: Suppose we wish to add a 'select statement to Core as follows: a select statement has the structure select bl -> si || b2 ->

 Suppose we wish to add a 'select statement to Core as

follows: a select statement has the structure select bl -> si ||

Suppose we wish to add a 'select statement to Core as follows: a select statement has the structure select bl -> si || b2 -> S2 || ... || bn -> Sn end; where bi, ..., bn are boolean expressions (i.e. (cond) 's), and si, ..., Sn are stmt seq) '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 bl 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 || is a new terminal symbol that is used to separate each (cond), stmt seq) pair from the next pair. (Actually, it is the same symbol that we are going to use in place of or in the Core grammar.) Now for the problems: 1. Make note of how much time you're spending on this homework so that you can estimate, to the nearest tenth of an hour, how much in answer to the last question. 2. During the time this homework is "active," i.e., from this class meeting to the next class meeting, make note of how much time you're spending on the current course project so that you can estimate, to the nearest tenth of an hour, how much in answer to the penultimate question. 3. (15 points) Add the select statement to Core by modifying the BNF grammar appropriately. (You may use extended BNF if you wish but answering the next question might then be harder.) 4. (30 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 use any of the three approaches we've discussed in class, the object-oriented approach, the ParseTree class, or directly use the array representation of the parse tree when answering this question. You may also assume procedures such as Execute-stmt-seq or functions like Eval-Cond, etc., already exist. Important Note: Problems 3 and 4 are not asking you to show how you can achieve the effect of the select statement by using multiple CORE-language 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; || (Y > 0) > X = 10; end; Suppose we wish to add a 'select statement to Core as follows: a select statement has the structure select bl -> si || b2 -> S2 || ... || bn -> Sn end; where bi, ..., bn are boolean expressions (i.e. (cond) 's), and si, ..., Sn are stmt seq) '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 bl 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 || is a new terminal symbol that is used to separate each (cond), stmt seq) pair from the next pair. (Actually, it is the same symbol that we are going to use in place of or in the Core grammar.) Now for the problems: 1. Make note of how much time you're spending on this homework so that you can estimate, to the nearest tenth of an hour, how much in answer to the last question. 2. During the time this homework is "active," i.e., from this class meeting to the next class meeting, make note of how much time you're spending on the current course project so that you can estimate, to the nearest tenth of an hour, how much in answer to the penultimate question. 3. (15 points) Add the select statement to Core by modifying the BNF grammar appropriately. (You may use extended BNF if you wish but answering the next question might then be harder.) 4. (30 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 use any of the three approaches we've discussed in class, the object-oriented approach, the ParseTree class, or directly use the array representation of the parse tree when answering this question. You may also assume procedures such as Execute-stmt-seq or functions like Eval-Cond, etc., already exist. Important Note: Problems 3 and 4 are not asking you to show how you can achieve the effect of the select statement by using multiple CORE-language 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; || (Y > 0) > X = 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!