Question: ( 2 0 pt ) Consider the switch statement in C - like languages, defined here according to this grammar: Switch longrightarrow switch (
pt Consider the switch statement in Clike languages, defined here according to this grammar:
Switch longrightarrow switch expr Cases Default
Cases longrightarrowmathrm Cases Case
Cases longrightarrow
Case longrightarrowmathrm case const: Stmt
Stmt longrightarrow stmt; break;
Stmt longrightarrowmathrm stmt;
Stmt longrightarrow
Default longrightarrow default: stmt;
Default longrightarrow
apt Compute the sets FIRSt and FOLlOW for all nonterminals and the sets
PREDICT for all production rules
bpt Prove that is not an grammar. Describe all conflicts.
cpt Build an LL grammar, equivalent with Compute, for the sets FIRST
and Follow for all nonterminals and the sets PrEdiCT for all production rules
dpt Show how the switch statement can be used, in general, to simulate any if then else
statement.
ept How is it possible that the switch statement can simulate if's and have an LL
grammar, since we said that there is no topdown grammar for if then. else statements?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
