考虑我的 vbscript 语法的这一部分
EXPR.Rule = BINARY_EXPR
| COMPARE_EXPR
| AND_EXPR
| OR_EXPR;
BINARY_EXPR.Rule = EXPR + BINARY_OP + EXPR + ReduceHere();
COMPARE_EXPR.Rule = EXPR + COMPARE_OP + EXPR + ReduceHere();
AND_EXPR.Rule = EXPR + "and" + EXPR;
OR_EXPR.Rule = EXPR + "or" + EXPR;
COMPARE_OP.Rule = ToTerm("=") | "<=" | ">=" | "<" | ">" | "<>";
BINARY_OP.Rule = ToTerm("+") | "&" | "^" | "-" | "*" | "/" | "\\";// | "=" | "<=" | ">=" | "<" | ">" | "<>" | "mod" | "and" | "or";
RegisterOperators(60, "^");
RegisterOperators(50, "*", "/", "\\", "mod");
RegisterOperators(40, "+", "-", "&");
RegisterOperators(30, "=", "<=", ">=", "<", ">", "<>");
RegisterOperators(20, "and", "or");
这个 vbscript 程序:
if 2=1+1 then x = 5
它将 this 解析为if (2=1)+1 then x = 5
而不是if 2=(1+1) then x = 5
. 我BINARY_EXPR
之前已经指定,COMPARE_EXPR
并且“+”具有更高的运算符优先级,所以我不知道如何告诉它应该首先寻找加法运算。我还能如何表达这一点,以便 Irony 以我想要的方式解析它?