1 回答
I have redesigned the grammar as follows, and that seem to have fixed the problem:
subst = multi_choice | machine_subst ;
multi_choice
= machine_subst
>> +( str_p("[]") >> machine_subst )
;
machine_subst
= ( multi_subst
| simple_subst
| if_select_pre_subst
| unbounded_choice )[&do_machSubst]
;
... ...
multi_subst = ( simple_subst
+( str_p("||") >> simple_subst ) ) [&do_mSubst] ;
simple_subst
= (identifier
>> str_p(":=") >> arith_expr) [&do_sSubst]
;
expression
= predicate
| logic_expr
| arith_expr
;
predicate
= ( logic_expr
>> +( ( str_p("&") >> logic_expr )
| ( str_p("OR") >> logic_expr ) ) )[&do_predicate]
;
logic_expr
= ( identifier
>> ( (str_p("<") >> arith_expr)
| (str_p(">") >> arith_expr)
| (str_p("/:") >> arith_expr)
| (str_p("<:") >> arith_expr)
| (str_p("/<:") >> arith_expr)
| (str_p("<<:") >> arith_expr)
| (str_p("/<<:") >> arith_expr)
| (str_p("<=") >> arith_expr)
| (str_p("=") >> arith_expr)
| (str_p(">=") >> arith_expr)
| (str_p("=>") >> arith_expr) )
) [&do_logicExpr]
;
... ... I now use the start rule "subst" for files f1.txt and f2.txt and "expression" for f3.txt and f4.txt.
start() const { return subst; //return machine_subst; //return expression; //return if_select_pre_subst; //return multi_choice; //return unbounded_choice; }
I am still building the grammar up, so if I have any further issues, I will post it.