Parser no longer compiles when upgrading from Boost 1.31 to Boost 1.33

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Parser no longer compiles when upgrading from Boost 1.31 to Boost 1.33

Paul Giaccone
I have just upgraded from Boost 1.31 to 1.33 and hence to Spirit 1.8.x.  
I am having the problem similar to that in FAQ #1, but the information
given there doesn't seem to help.

Here is a code snippet from my grammar (modified a little to protect
intellectual property rights):

    end_of_block = close_brace >> semicolon;

    variable_list = while_p(~eps_p(end_of_block))[token];

    token_definition =
                token_name_guard(expect_token_name((longest_d[name1 |
name2] >> eps_p)[&set_token]))[handle_invalid_token()] >>
                (
                    (open_brace >> defA) |
                    (open_bracket >> defB) |
                   
bracket_guard(test_open_bracket)[handle_dangling_token()]
                );

    [...]

    chlit<> semicolon, close_brace;

The character constants semicolon and close_brace are defined in the
constructor for definition:

    definition(MyGrammar const&) : semicolon(';'), close_brace('}')

This compiled and ran fine with Boost 1.31, but now I get:

D:\boost\include\boost-1_33\boost\spirit\core\non_terminal\impl\rule.ipp(190):
error C2664: 'boost::spirit::match_result<MatchPolicyT,T>::type
boost::spirit::impl::abstract_parser<ScannerT,AttrT>::do_parse_virtual(const
ScannerT0 &) const' : cannot convert parameter 1 from 'const
boost::spirit::scanner<IteratorT,PoliciesT>' to 'const scanner_t &'
        with
        [
            MatchPolicyT=scanner_t,
            T=boost::spirit::grammar<MyGrammar>::attr_t,
           
ScannerT=boost::spirit::rule<MyGrammar::definition<scanner_t>::scanners>::scanner_t,
           
AttrT=boost::spirit::rule<MyGrammar::definition<scanner_t>::scanners>::attr_t,
            ScannerT0=scanner_t
        ]
        and
        [
           
IteratorT=boost::spirit::scanner<pos_iterator,scanner_policies_t>::iterator_t,
           
PoliciesT=boost::spirit::no_actions_scanner<boost::spirit::lexeme_scanner<scanner_t>::type>::policies_t
        ]

As suggested in FAQ #1, I have introduced a list of scanners to replace
the bare ScannerT type.  I've defined this as:

        typedef boost::spirit::scanner_list<ScannerT,
            typename boost::spirit::lexeme_scanner<ScannerT>::type,
            typename boost::spirit::no_actions_scanner<ScannerT>::type
        > scanners;

The rule returned by my grammar is of type rule<ScannerT> and the other
rules from which it is built up are of type rule<scanners>.

(I do not seem to need this list of scanners, though: if I just use
ScannerT, this does not introduce any extra errors.)

Note that I have an similar rule earlier on in my grammar that does not
generate any errors:

            block_list = while_p(~eps_p(end_p))[block];

where

            block = block_guard(
                expect_block(
                            (semicolon_guard(block1 >>
test_semicolon)[handle_missing_semicolon_at_end_of_block()]) |
                            (semicolon_guard(block2 >>
test_semicolon)[handle_missing_semicolon_at_end_of_block()]) |
                            (semicolon_guard(block3 >>
test_semicolon)[handle_missing_semicolon_at_end_of_block()])
                            )
                    )[handle_non_block()];

The problem seems to lie with eps_p(end_of_block), as if I replace
end_of_block with end_p, the grammar compiles (although if course it
will not then do what I want it to do).

Can you suggest what might be wrong and how I can resolve it?  Is it
that end_of_block needs to be a parser rather than a rule, or do I have
to make changes to the list of scanners?

Thanks,

Paul



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Parser no longer compiles when upgrading from Boost 1.31 to Boost 1.33

Paul Giaccone
Paul Giaccone wrote:

> I have just upgraded from Boost 1.31 to 1.33 and hence to Spirit
> 1.8.x.  I am having the problem similar to that in FAQ #1, but the
> information given there doesn't seem to help.
>
> Here is a code snippet from my grammar (modified a little to protect
> intellectual property rights):
>
>    end_of_block = close_brace >> semicolon;
>
>    variable_list = while_p(~eps_p(end_of_block))[token];


I found out what the problem was and how to fix it in the end.  The rule
end_of_block has no actions, so I defined a scanner list containing
ScannerT and the no-actions scanner, and made end_of_block of type
rule<scanners> instead of rule<ScannerT>, as below.  The code then compiled.

    typedef boost::spirit::scanner_list<ScannerT, typename
boost::spirit::no_actions_scanner<ScannerT>::type> scanners;
    rule<scanners> end_of_block;

Paul



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general