I am trying to parse the lines ::
10.1.1.1/32 10.10.1.1 29/nolabel
10.7.7.7/32 150.2.2.2 nolabel/30
Which are space separated and putting them in a vector of strings ::
sp %= lit(' ');
ip_address %= +char_("0-9") >> char_('.') >> +char_("0-9") >> char_('.') >> +char_("0-9") >> char_('.') >> +char_("0-9")
>> *char_("/") >> *char_("0-9");
data %= *sp >> ( xr_special | ip_address | +lit("/") | +char_("0-9A-Za-z()"));
start %= +(data ) >> *sp >> eoi;
qi::rule sp;
qi::rule ip_address;
qi::rule data;
qi::rule start; (Parsed Rec carries a vector of strings )
Grammar is able to parse the lines but while parsing 29 in first line & 30 in last line, the attributes are incorrectly filled. The attributes are filled twice ( Debug File for this is debug_file_incorrect).
Snippet ::
<data>
<try> 29/nolabel</try>
<try>29/nolabel</try>
<fail/>
<try>29/nolabel</try>
<fail/>
<success>/nolabel</success>
<attributes>[[2, 9, 2, 9]]</attributes>
</data>
While if I change my grammar to explicitly fill the attributes, they are filled correctly. File attached : debug_file_correct
data = *sp >> ( xr_special | ip_address[_val= _1] | +lit("/") | +char_("0-9A-Za-z()")[_val+= _1] );
<data>
<try> 29/nolabel</try>
<try>29/nolabel</try>
<fail/>
<try>29/nolabel</try>
<fail/>
<success>/nolabel</success>
<attributes>[[2, 9]]</attributes>
</data>
Thanks
Preeti