Boost logo

Boost Users :

Subject: [Boost-users] [Spirit] parse tree node does not get produced with Single character input.
From: Philippe forest (philippe.forest_at_[hidden])
Date: 2010-06-08 11:03:27


Hi,

First of all I would like to state that
spirit =
  str_p("very") >> +ch_p(' ') >>( str_p("nice") | str_p("cool") |
str_p("greate") ) >> +ch_p(' ') >> str_p("parser")
;

So Thanks for that.

But I do face a problem. When assigning ID to nodes of the parse tree.
ex: rule<ScannerT, parser_context<>, parser_tag<stringID> > String;

I've attached a sample to demonstrate the problem.

In short:

The grammar below does not produce a parse tree node with a 'stringID'
when the input is a single character 'a'. As soon as I have 2 or more
characters 'aa' then I get a node stringID.

         definition(
          ExpressionNoStringIDGrammar const& /*self*/)
        {
          Char =
            ch_p('a')
            ;

          String =
            ( +Char )
            ;

          language =
            String
            ;
        }

rule<ScannerT, parser_context<>, parser_tag<charID> > Char;
rule<ScannerT, parser_context<>, parser_tag<stringID> > String;
rule<ScannerT> language;

BUT:
If I remove the 'Char' parser and substitute it with ch_p('a') then it
works fine , then I always get a node stringID even with a single input
char.

         definition(
          ExpressionNoStringIDGrammar const& /*self*/)
        {
          String =
            ( +ch_p('a') )
            ;

          language =
            String
            ;
        }

rule<ScannerT, parser_context<>, parser_tag<charID> > Char;
rule<ScannerT, parser_context<>, parser_tag<stringID> > String;
rule<ScannerT> language;

Could anyone either explain me what is going on ?
 - I'm I doing something wrong or is this a bug or works as designed ?

Thanks Again

Phil.




Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net