



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; Class: PROGRAM LANG CONCEPTS; Subject: COMPUTER PROGRAMMING; University: University of Florida; Term: Spring 2008;
Typology: Exams
1 / 5
This page cannot be seen from the preview
Don't miss anything!




(100 points, 2 hours)
1. Parser Construction: (25 points) Below is the portion of the RPAL grammar that handles tuple and conditional expressions. Write the pseudo-code for the corresponding portion of a recursive descent parser. Assume the existence of procedure B. Include in your parser the necessary “BuildTree” statements to build the Abstract Syntax Tree, in bottom-up fashion. T -> Ta ( ‘,’ Ta ) + => ‘tau’ -> Ta ; Ta -> Ta ‘aug’ Tc => ‘aug’ -> Tc ; Tc -> B ‘->’ Tc ‘|’ Tc => ‘->’ -> B ;
3. Show the Abstract Syntax Trees for the following RPAL programs: (25 points) (1) f (5, 4) where ( h (a, b) = a – b within f x = h x )
(2) let t = m and n = 2 * m where m = 1 in t ls (n ls 1)
(3) let n (m) = m / 2 + 1 in n (m) where p = 6
(4) m or n -> p -> m | n | n
4. Writing RPAL Programs: (25 points) The following RPAL program is overly parenthesized; remove all superfluous parentheses, i.e. minimize the parentheses without changing the meaning of the program: (let (x =((a * b)/c)) in ((e or f) -> (g -> x ** (x*2)|y) | (f(x) where (( f(y) = (y2)) and (x=(3 + (x * 2))))))) Also, "beautify" the program by re-writing it on several lines with the appropriate indentation.