Boost logo

Boost :

Subject: Re: [boost] problems with grammar using spirit
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2011-08-29 08:22:06


> Hi! I'm new using spirit and I'm having trouble with the parser. I already
> make this scanner and parser using CocoR but I have had no succes with
> spirit. Patito2011 is the main grammar but when I read the input file it
> doen't follows this grammar it goes directly to the Vars grammar. I don't
> know what is wrong help is appreciated.
>
> Patito2011 = tok.plan >> tok.id >> ';' >> -Vars >> Parvada >> tok.end_;

The reason your parser is failing is that your lexer does not recognize the
':' delimiting the variable declarations. Moreover, I'd suggest you change
the way you skip whitespace. It's much more efficient if you do that in the
lexer itself (by ignoring whitespace tokens) than to defer to the skipper.
I'm attaching a (partially) corrected example which stops matching at the
':'.

Regards Hartmut
---------------
http://boost-spirit.com




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk