



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CMSC 330, Spring 2008, Midterm 2 Practice Problems
For the following grammar: S → S and S | S or S | true e. List all parse trees for the string “true and true or true”
f. What is implied about the precedence/associativity of “and” and “or” for each parse tree? g. Rewrite the grammar so that “and” has higher precedence than “or” and is right associative
ff. let rec f = function [] -> 0 | (h::t) -> h + (2*(f t)) gg. let rec func (f, l1, l2) = match l1 with [] -> [] | (h1::t1) -> match l2 with [] -> [f h1] |(h2::t2) -> [f h1; f h2]
p. let rec x y = y in x 1 q. let x y = fun z -> z+1 in x r. let x y = fun z -> z+1 in x 1 s. let x y = fun z -> z+1 in x 1 1 t. let x y = fun z -> x+1 in x 1 u. let rec x y = fun z -> x+1 in x 1 v. let rec x y = fun z -> x+y in x 1 w. let rec x y = fun z -> x y in x 1 x. let rec x y = fun z -> x z in x 1 y. let x y = y 1 in 1 z. let x y = y 1 in x aa. let x y = y 1 in x 1 bb. let x y = y 1 in x fun z -> z + 1 cc. let x y = y 1 in x (fun z -> z + 1) dd. let a = 1 in let f x y z = x+y+z+a in f 1 2 3 ee. let a = 1 in let f x y z = x+y+z+a in f 1 2 -