The rule to parse something like "a.b.c" and "a().b"
postfix =
primary [_val=_1] >> *(
(lit('(') > paralistopt > lit(')')) [_val = construct<common_node>(type_cmd_fnc_call,key_this, construct<common_node>(_val), key_parameter, construct<std::vector<common_node> >(_1))]
| (lit('.') > name_pure) [_val = construct<common_node>(type_cmd_dot_call,key_this, construct<common_node>(_val), key_propname, construct<std::wstring>(_1))]
)
;
The annotation code for the rule (common_node is the AST entry)
void annotateNode(parserDataS & data,const std::wstring::const_iterator & pos1, const std::wstring::const_iterator & pos2, common_node & node)
{
// calc pos
int p1=std::distance(data.init_pos, pos1);
int p2=std::distance(data.init_pos, pos2);
// range is from >=p1 <=p2
node.makeLocation(std::make_pair(p1, p2-1));
}
handler Setup
on_success(postfix, phoenix::bind(&annotateNode, phoenix::ref(parserData),_1, _3,_val))
So far no problem, using "a.b" the annotation is called on the node. But when using a.b.c.d the "on_success" is only called on the first node "a" for each member (b,c,d) How to code the "on_succcess" for each member .. "a.b" "(a.b).c" "(a.b.c).d" separate ?