#Homework 3#
-
#####Consider the context-free grammar:
S -> S S + | S S * | a
and the stringaa + a*
.- Give a leftmost derivation for the string.
- Give a rightmost derivation for the string.
- Give a parse tree for the string.
-
#####Construct unambiguous context-free grammars for each of the following languages.
- Arithmetic expressions of integers and identifiers
with the four binary operators
+, -, *, /
. - Add unary plus and minus to the arithmetic operators of the previous question.
- Arithmetic expressions of integers and identifiers
with the four binary operators
-
#####Is it possible, by modifying the grammar in any way, to construct a predictive parser for the language of Question 1 (postfix expressions with operand a)?
-
#####Compute FIRST and FOLLEW for the grammar of Question 1.
-
#####For the SDD shown below, give annotated parse trees for the following expressions:
(3+4)*(5+6) n.
1*2*3*(4+5) n.