Question
1. The programming language Pascal has a repeat...until construct for a logical post-test loop. The syntax is given by the following BNF (with the relevant
1. The programming language Pascal has a repeat...until construct for a logical post-test loop. The syntax is given by the following BNF (with the relevant production underlined):
--> | | | // Syntax and semantics for , , and are as given in // slides (using an attribute grammar).
--> repeat until (id[1] relop id[2])
The loop executes the statement(s) between the repeat and the until, tests the logical condition following the until keyword, and repeats the loop body if the condition is false. If exits the loop when the condition is true. Note that it always executes the loop body at least once.
Extend the attribute grammar from the slides to include operational semantics for repeat...until loops.
2. Use the operational semantics for repeat...until loops from exercise 5 to produce a decorated parse tree and intermediate code for the following loop:
repeat
alpha = alpha + 2*beta
until (alpha > gamma)
5. The programming language Pascal has a repeat...until construct for a logical post-test loop. The syntax is given by the following BNF (with the relevant production underlined):Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started