dragon-book-exercise-answers
dragon-book-exercise-answers copied to clipboard
2.3.2 translation schemes
是不是应该这样: expr -> {print("(")}expr {print(")+(")} expr {print(")")} + | {print("(")}expr {print(")-(")} expr {print(")")} - | {print("(")} expr {print(")*(")} expr {print(")")} * | {print("(")} expr {print(")/(")} expr {print(")")} / | digit {print(digit)}
因为 - + 那2行不加括号的话: 321+- => 3-2+1 0 => 2 最后,谢谢你的答案
Yup. Even I think you shouldn't omit the parentheses in + and - productions. Consider the case when it's mixed up with higher precedence operators.