资 源 简 介
这是一份实验报告,目的是掌握YACC的使用方法,了解YACC处理二义性的方法。
用YACC等工具生成如下文法表示的表达式对应的计算器
exp->exp + exp | exp - exp| exp * exp |exp / exp |exp ^ exp | - exp |(exp) |NUM
对于输入的表达式,能输出结果。比如:
3 +(4 *5)结果应为23
当出现错误时可以进行错误处理。
-This is a test report, the purpose is to master the use YACC to learn YACC handling of the ambiguity approach. Using tools such as YACC grammar that generates the following expression for the corresponding calculator exp-> exp+ exp | exp- exp | exp* exp | exp/exp | exp ^ exp |- exp | (exp) | NUM expression for the input type, can be output. For example: 3+ (4* 5) the result should be 23 when the error can be error-handling.