Skip to content

X3: BOOST_SPIRIT_INSTANTIATE regression #453

Description

@Xeverous

after a3cf3f2 X3 requires existing code to change grammar to add more const x3::unused_type workarounds

This compiles fine just before a3cf3f2:

    #include <boost/spirit/home/x3.hpp>

    namespace x3 = boost::spirit::x3;

    using comment_type = x3::rule<class comment_class, /* const */ x3::unused_type>;
    BOOST_SPIRIT_DECLARE(comment_type)

    using identifier_type = x3::rule<class identifier_class, std::string>;
    BOOST_SPIRIT_DECLARE(identifier_type)

    using whitespace_type = x3::rule<class whitespace_class, /* const */ x3::unused_type>;
    BOOST_SPIRIT_DECLARE(whitespace_type)

    using grammar_type = x3::rule<class grammar_class, std::string>;
    BOOST_SPIRIT_DECLARE(grammar_type)

    using skipper_type = whitespace_type;
    using iterator_type = std::string::const_iterator;
    using context_type = x3::phrase_parse_context<skipper_type>::type;

    const comment_type comment = "comment";
    const auto comment_def = x3::lexeme['#' >> *(x3::char_ - '\n')];
    BOOST_SPIRIT_DEFINE(comment)

    const identifier_type identifier = "identifier";
    const auto identifier_def = x3::lexeme[(x3::alpha | '_') >> *(x3::alnum | '_')];
    BOOST_SPIRIT_DEFINE(identifier)

    const whitespace_type whitespace = "whitespace";
    const auto whitespace_def = x3::space;
    BOOST_SPIRIT_DEFINE(whitespace)

    const grammar_type grammar = "code";
    const auto grammar_def = identifier > comment;
    BOOST_SPIRIT_DEFINE(grammar)

    BOOST_SPIRIT_INSTANTIATE(grammar_type, iterator_type, context_type)

but after that commit, all grammars that do not syntesize any attribute have to specify const x3::unused_type (uncomment const)

Unfortunately the pull mentioned in https://stackoverflow.com/a/54095167/4818802 does not solve the problem, it only requires code to have more workarounds than previously.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions