boost::spirit::qi duplicate parsing on the output

后端 未结 2 829
无人及你
无人及你 2020-11-28 16:28

I have this very simple parser using Boost::Spirit:

rule zeroTo255 = (string(\"25\") >> char_(\'0\', \'5\')         


        
2条回答
  •  时光说笑
    2020-11-28 17:16

    I faced a similar problem once. This is the particular way the alternative operator in Spirit works. Your example should work if you use additional directive "hold".

    rule zeroTo255 
    = hold[string("25") >> char_('0', '5')]
    | hold[char_('2') >> char_('0', '4') >> digit]
    | hold[char_('1') >> repeat[2](digit)]
    | hold[char_('1', '9') >> digit] | digit;
    

    For details of this behavior see this thread.

提交回复
热议问题