[Spirit] parse tree node does not get produced with Single character input.
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
I know this is old, but it has had no response, I apologize...
On Tue, Jun 8, 2010 at 9:03 AM, Philippe forest
Hi,
Greetings,
You should update your Boost, the later versions are vastly better,
allow me to demonstrate:
On Tue, Jun 8, 2010 at 9:03 AM, Philippe forest
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") ;
In modern Spirit: spirit = skip(' ')[lit("very") >> (lit("nice") | "cool" | "great") )>>"parser"] ;
So Thanks for that.
But I do face a problem. When assigning ID to nodes of the parse tree. ex: rule
, 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
, parser_tag<charID> > Char; rule , parser_tag<stringID> > String; rule<ScannerT> language;
In modern Spirit, this should work fine:
template<typename Iterator>
class definition : grammar
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
, parser_tag<charID> > Char; rule , 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 ?
participants (2)
-
OvermindDL1
-
Philippe forest