提问人:QuickDzen 提问时间:11/10/2023 更新时间:11/10/2023 访问量:18
eBNF 语法中的运算符优先级
Operators priority in eBNF grammar
问:
我有以下 eBNF 语法:
expression = term { add_operator term }
term = factor { mul_operator factor }
factor = "(" expression ")" | variable | number
add_operator = "+" | "-"
mul_operator = "*" | "/"
variable = letter { letter | digit | "_" }
letter = "a" | "b" | ... | "z"
number = [sign] digit { digit }
digit = "0" | "1" | ... | "9"
sign = "-"
为什么我需要因子、项和不同的运算来mul_operator和add_operator。运营商有必要优先吗?如果是,它将如何工作?
答: 暂无答案
评论