

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Bermudez; Class: PROGRAM LANGUAGE PRIN; Subject: COMPUTER PROGRAMMING; University: University of Florida; Term: Unknown 1989;
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Instructor: Manuel Bermudez
SAMPLE FINAL QUESTIONS (denotational semantics, actually)
Add procedures to the denotational description of Tiny. We will consider proce- dures with one parameter, and with no local variables, but the procedures are recursive. Two new constructs need to be handled: a procedure declaration, and a procedure call.
Complete the following:
CC[
CC[
Hint: Treat the procedure declaration as an asignment to the procedure name I.
Add the Algol ’for’ loop to the the denotational description of Tiny. The Algol ’for’ loop has the following syntax:
Statement -> ’for’ ’
For example:
for i:= 0, 8, 9, 8..19, 7..3 do output(i)
Note: ranges are intended to count ’upwards’ only. Complete the following:
CC[<’for’ <id:x> IE 1 ... IEn C>] =
Hint: Consider defining CC for a new ’on-the-fly’ construct, that will process exactly one
IntExp, be it a single integer or a range of integers.
Let’s specify the semantics of a language of integer (no fractions) binary numbers.
Below is the AST grammar for binary numbers.
B → < ’bin’ E B > → ’0’ E → < ’cat’ E D > → D D → ’0’ → ’1’
Below is a sample AST, produced from the input string The numbers are 4+2=6, and 2+1=3.
bin ____/ __ /
cat bin / \ /
cat 0 cat ’0’ / \ /
1 1 cat 1 /
0 1
The following are the semantic domains:
Num = { 0, 1, 2,... } Output = Num * (tuples of numbers)
The following are the functionalities of the semantic functions:
EE: E → Num BB: B → Output → Output
Fill in the following lines to complete the denotational semantic description of the lan- guage. Hints: the meaning of a binary number tree X, such as the one above, is BB [X] nil. The cascade of "bin" nodes is intended for BB to take the current output, augment it with value of the current binary number, and pass the new output along to the next "bin" node. A cascade of "cat" nodes is intended for EE to calculate the value of the binary number, from left to right.
EE [’1’] = EE [’0’] = EE [< cat E D > ] = BB [< ’bin’ E B > ] = BB [’0’] =