Programming Language Concepts - Sample Final Exam 2008 | COP 4020, Exams of Computer Science

Material Type: Exam; Class: PROGRAM LANG CONCEPTS; Subject: COMPUTER PROGRAMMING; University: University of Florida; Term: Spring 2008;

Typology: Exams

Pre 2010

Uploaded on 09/17/2009

koofers-user-42d
koofers-user-42d 🇺🇸

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COP4020
Programming Language Concepts
Spring 2008 Sample Final Exam
(100 points, 2 hours)
pf3
pf4
pf5

Partial preview of the text

Download Programming Language Concepts - Sample Final Exam 2008 | COP 4020 and more Exams Computer Science in PDF only on Docsity!

COP

Programming Language Concepts

Spring 2008 Sample Final Exam

(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.