问题
This switch statement is working with one Case how to make it multiple case
S: Statement {printf("ACCEPTED");}
Statement:SWITCH BRO ID BRC CBO E CBC
E: A
| A C
A: A B
| CASE DIGIT D
B: BREAK SEMI
C : DEFAULT D B
D : COLON ID SEMI
;
This is an issue i want to make grammar accepted with multiple cases

回答1:
Your grammar is terrible, and does not account for repetition of the CASE. You need to discover how to express lists of things. The general pattern is like:
item: ....
items: item
| item ';' items
So we have:
case: CASE DIGIT ':' stmts
default: DEFAULT ':' stmts
cases: case | default | case ';' cases
You should also find out how you can trace the parser for debugging. With yacc, you can set the environment variable YYDEBUG and it will print a quite verbose of all parser states.
回答2:
Correct switch grammar Don't need to use semicolon in between A E space will work.
Statement:SWITCH BRO ID BRC CBO E CBC
E: A | A C | A E
A: A B | CASE DIGIT D
B: BREAK SEMI
C : DEFAULT D B
D : COLON ID SEMI
来源:https://stackoverflow.com/questions/21073980/this-switch-statement-is-working-with-one-case-how-to-make-it-multiple-case-biso