此switch语句与一个Case一起使用如何使它成为多Case Bison [英] This switch statement is working with one Case how to make it multiple case Bison
问题描述
此switch语句与一个Case一起使用,如何使其变为多种大小写
This switch statement is working with one Case how to make it multiple case
S: Statement {printf("ACCEPTED");}
声明:SWITCH BRO ID BRC CBO E CBC
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
推荐答案
您的语法很糟糕,并且不说明CASE的重复.您需要发现如何表达事物列表.一般模式如下:
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
所以我们有:
case: CASE DIGIT ':' stmts
default: DEFAULT ':' stmts
cases: case | default | case ';' cases
您还应该了解如何跟踪解析器进行调试.使用yacc,您可以设置环境变量YYDEBUG,它将显示所有解析器状态的详细信息.
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.
这篇关于此switch语句与一个Case一起使用如何使它成为多Case Bison的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!