I have a question on semantic actions on boost spirit with the ">" operator
I got this rule which works perfectly ..
ifelse = (iter_pos >>
nocaselit(L"if") >> expression >> nocaselit(L"then") >>
block_statements_eol >> -ifelse_ifelse >> nocaselit(L"end") >> nocaselit(L"if") >>
iter_pos)
[_val = construct<common_node>(type_cmd_ifelse,LOCATION(_1,_5), key_cond, _2, key_seq, _3, key_else, phoenix::bind(&makeOptNode, _4))];
To add some error handling I also add the on_error stuff to my parser. As far I understood I also have to add “expectation points” for boost to output the error correct
So I change the grammar to this one (replace the >> with >) to give information about stop backtracking and report errors.
ifelse = (iter_pos >>
nocaselit(L"if") > expression > nocaselit(L"then") >>
block_statements_eol > -ifelse_ifelse > nocaselit(L"end") > nocaselit(L"if") >>
iter_pos)
[_val = construct<common_node>(type_cmd_ifelse,LOCATION(_1,_5), key_cond, _2, key_seq, _3, key_else, phoenix::bind(&makeOptNode, _4))];
At this point I get the C++ compiler error invalid index for _3 and _4 .. so it seems that the semantic action has to be changed in some way but I have no idea how.