Gmane
From: Pierre Raoul <pierre-m.raoul <at> wanadoo.fr>
Subject: skip grammar and end of file
Newsgroups: gmane.comp.parsers.spirit.general
Date: 2003-05-01 01:40:21 GMT (5 years, 31 weeks, 20 hours and 6 minutes ago)
Hello,

When I try this code

[...]
struct testgrammar : public grammar<testgrammar>
{
    testgrammar() {}   
    template <typename ScannerT>
    struct definition
    {
        definition(testgrammar const& /*self*/)
        {
            real = lexeme_d[ +digit_p ][echo_real_action()];

            name =
                lexeme_d[ alpha_p >> *alnum_p ][echo_text_action()] ;

            statement = *( real | name ) ;
        }
        rule<ScannerT> const&
        start() const { return statement ; }
        rule<ScannerT>  statement, real, name ; 
    } ;
} ;
[...]
struct skip_p : public grammar<skip_p>
{
    skip_p() {}
    template <typename ScannerT>
    struct definition
    {
        definition(skip_p const& /*self*/)
        {
            skip =
                   (space_p)[echo_space_action()]
                ;
        }
        rule<ScannerT> const&
        start() const { return skip ; }
        rule<ScannerT> skip ;
    } ;
} ; 
[...]
        vector<char>::const_iterator first = vec.begin() ;
        vector<char>::const_iterator last = vec.end() ;
        skip_p skip ;
        testgrammar p ;
        parse_info<vector<char>::const_iterator > info =
             parse(first, last, p, skip) ;
[...]

then info.full is false each time that some spaces are at the end of the vector, after the last item parsed by
testgrammar. 

It seems to me that the expected way would be an info.full at true in such cases.

Can you confirm that to avoid this problem, the only ways are:
- either to use a free parse function at character level,
- or use a while statement on info.hit at true to get each parsed item.

Thanks

Pierre Raoul 

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf