Skip to content

Can't use a rule parameter to pass a symbol table to a rule? #246

@jwwalker

Description

@jwwalker

I tried the following, and the compiler wasn't happy about it. I guess the tutorial's discussion of parameters was too complicated for me.

#include <boost/parser/parser.hpp>

namespace bp = ::boost::parser;

bp::rule< struct toprule, double > toprule = "toprule";
auto const toprule_def = bp::double_ >> bp::_p<0>;
BOOST_PARSER_DEFINE_RULES( toprule );

static void ParamTest( const bp::symbols<double>& syms )
{
    auto result = bp::parse( "10.3", toprule.with( syms ), bp::ws );
}

By the way, am I correct that a rule must be defined at global scope?

See also a discussion on Stack Overflow, where a reply said "you're looking for lazy rule references" but I don't really know what that means.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions