我正在使用 Jflex、byacc、java 来解析语句,它看起来像
where expr,expr having expr
语法看起来像
%token WHERE HAVING COMMA
%%
stmt : whereclause havingclause
whereclause : WHERE conditionlist { move tmpList to whereClause};
havingclause : HAVING conditionlist { move tmpList to havingClause};
conditionlist : condition | condition COMMA conditionlist;
condition : expr { tmpList.add($1);
/How do I know this is being executed for whereclause or havingclause /};
expr : ....
我无法区分条件是 whereclause 还是 havingclause 的一部分,因此我将条件存储在临时列表中,然后移至正确的子句。这样做的正确方法是什么?