Using boost::ref on phoenix::closures using boost::spirit v1

Another boost::spirit question.

The boost::spirit documentation gives the following example of parametric
parser:

taken from http://www.boost.org/doc/libs/1_33_1/libs/spirit/doc/parametric_parsers.html
1
2
3
4
5
6
char ch = 'A';
char from = 'A';
char to = 'Z';

ch_p(boost::ref(ch))
range_p(boost::ref(from), boost::ref(to))


I'd like to build a parser that parses expressions of the form

A-B

where A and B are non-negative integers and B >= A. So here's
the rule I defined:

1
2
3
4
5
6
   int_range = 
         uint_p[int_range.lower_bound = arg1 ]
      >> '-'
      >> min_limit_d( boost::ref( int_range.lower_bound ) )[ uint_p ]
            [int_range.upper_bound = arg1 ]
   ;


with the following declarations:

1
2
3
4
5
6
7
8
9
struct int_range_closure : 
    public boost::spirit::closure< int_range_closure, uint32_t, uint32_t >
{
    member1 lower_bound;
    member2 upper_bound;
};

// and the rule is declared as:
boost::spirit::rule<ScannerT, int_range_closure::context_t> int_range;


But the rule does not compile; it complains because of use of
closure member.

Furthermore, I do not want to leave it up to the semantic actions
to check B >= A (for various reasons which will ultimately lead me
to posting new questions).

Ideas of why this doesn't work or how to make it work?

Last edited on
Topic archived. No new replies allowed.