Question: Answer questions ( a ) through ( c ) for the following grammar: val :: = number | val pair number :: = digit +

Answer questions (a) through (c) for the following grammar:
val ::= number | val pair
number ::= digit+
pair ::= number op | number pair op
op ::="+"|"-"|"*"|"/"
digit ::="0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
Also consider the following mutation, which adds an additional rule to the grammar:
pair ::= number op | number pair op | op number
1. Which of the following strings can be generated by the (unmutated) grammar?
a)42
b)42
c)4+2
d)42+
e)427-*
f)42-7*
g)42-7*+
2. Find a string that is generated by the mutated grammar, but not by the original grammar.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!