2 Jan 04:11
Re: Composite parse with action?
Joel de Guzman <joel <at> boost-consulting.com>
2009-01-02 03:11:41 GMT
2009-01-02 03:11:41 GMT
Max Pfingsthorn wrote: > Dear list, > > This is my first time with parsers and such, so I hope my question is > not too stupid. > > I would like to write a config file parser with Spirit. So far, that is > not a problem, however, I would like to use the grammar from the > calculator example as the parser for numeric expressions (so I can write > > somevalue = 3*pi/2; > > in my config file and somevalue will be 4.71239 instead of some string). > > I have gotten as far as implementing the completely working calculator > in a grammar<> subclass (it keeps a stack of values and actually > performs the operations instead of just printing to stdout). Now, the > only last thing I have left is how to attach an action to that grammar. > Basically, I would like the action function to not care if it is > attached to a real_parser or my calculator grammar. Is that possible? Yes. > What do I have to do to "return" a double value properly? I tried to > read the code for real_parser, but I got lost... If you are using "classic" spirit, then I think there's an example doing that (see the calculators in the example/fundamental) directory. Basically, a grammar is just another parser in the POV of Spirit.(Continue reading)
Thanks for bringing it
into attention.
> It looks to me as though there is one set for both input and output which
> remains in effect once set. Is that correct?
Regards,
RSS Feed