Docsity

Program Languages Concepts - Solved Problem Set 3 | COP 4020, Assignments of Computer Science

Toggle sidebar
bg1
COP4020 Spring 2008 Homework-3 Solutions
1. Using the RPAL string-to-tree-transduction grammar, construct the abstract syntax tree (if
possible) for each of the following programs:
(a) x or y -> x | z -> x | y
(b) a < b -> c -> a | b | a
(c) x aug y, z, 3
(d) x, y, z aug 3
(e) let f (x) = x + 2 * 1 in f (z) where z = 6
(f) let x = z and y = 2 * z where z = 3 in x ** y ** y
(g) let a = c in a * b ** c where ( z = 3 and y = 2 * z )
(h) let a = c in a * b ** c where z = 3 and y = 2 * z
Answer:
(a)
(b)
(c)
(d)
pf3

Partial preview of the text

Download Program Languages Concepts - Solved Problem Set 3 | COP 4020 and more Assignments Computer Science in PDF only on Docsity!

COP4020 Spring 2008 Homework-3 Solutions

1. Using the RPAL string-to-tree-transduction grammar, construct the abstract syntax tree (if possible) for each of the following programs: (a) x or y -> x | z -> x | y (b) a < b -> c -> a | b | a (c) x aug y, z, 3 (d) x, y, z aug 3 (e) let f (x) = x + 2 * 1 in f (z) where z = 6 (f) let x = z and y = 2 * z where z = 3 in x ** y ** y (g) let a = c in a * b ** c where ( z = 3 and y = 2 * z ) (h) let a = c in a * b ** c where z = 3 and y = 2 * z

Answer: (a)

(b)

(c)

(d)

(e)

(f)

(g)

(h) No AST is possible.