次のようなステートメントを解析するために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の一部であるかどうかを区別できないため、条件を一時リストに保存してから、正しい句に移動しています。これを行う正しい方法は何ですか?