

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!


(a) fan^ bn^ j n 0 and n is even g (b) fai^ bj^ c^2 i+1^ dk^ j i; j; k 0 g (c) fa 1 a 2 :::an an :::a 2 a 1 j ai 2 fa; bg; 1 i ng (d) fam^ bn^ am+n^ j m 0 and n 1 g (e) fan^ bm^ an m^ j n m 0 g (f ) All p ossible sequences of balanced parentheses (g) fw j w 2 fa; bg and w has an o dd numb er of a's and an o dd numb er of b's g. (h) fw j w 2 fa; bg and w has an equal numb er of a's and b's g (i) fam^ bn^ cp^ dq^ j m + n = p + q g (j) fam^ bn^ j m 6 = n and m; n 0 g (k) fw j w 2 fa; bg and w contains no substrings of the form abg (l) fw j w 2 fa; bg and every pair of a's is followed by at least one b g
fan^ bn^ am^ bm^ j m; n 1 g [ fan^ bm^ am^ bn^ j m; n 1 g
If your grammar is ambiguous, prove that it is.
(a) Op erators in APL are right asso ciative and have equal precedence, unless altered by parentheses. The op erators +, -, *, / can app ear as b oth monadic (unary) and dyadic (binary) op erators. Assignment ( ) is also treated as a binary op erator that returns the value assigned as its result. Write an unambiguous context free grammar for APL expressions containing the op erands a, b, and c. (b) Prop ositional calculus formulas having op erators unary and binary , op erands p and q, and parentheses. The op erators should b oth b e right asso ciative and have their usual precedence. (c) C++ expressions with identi ers a and b and op erators - >, *, and ++. - > is a left asso ciative binary op erator, * is a right asso ciative unary op erator, and ++ is a right asso ciative p ost x op erator. The unary op erators have precedence lower than the p ost x expressions but higher than all binary op erators. For example, the expression *a++ increments a b efore dereferencing it.
Develop another grammar for this language that enforces the restriction that a call must have the same numb er of arguments as the declaration (you can treat