From: Dave Gomboc (dave_at_[hidden])
Date: 2003-03-26 08:03:05
When I define rules x, y, and z such that
x = ch_p('a');
y = ch_p('a');
z = !x >> y;
it appears to operate the same as if z were defined to be
z = (ch_p('a') | epsilon_p) >> 'a';
which accepts "aa", but rejects "a".
On the other hand, if I define z as
z = (epsilon_p | ch_p('a')) >> 'a'
then "a" is accepted, but "aa" is rejected.
(These are, of course, not the actual rules I am interested in, but a vast
simplification of them, focusing on the point of interest.)
My original expectation had been that first the choice on the left side of
the or operation would be attempted, but when ultimately failing to match
the entire string later on, to then backtrack and attempt matching via the
choice on the right side of the or. How can I achieve this behaviour?
In the real problem the semantic actions associated with x and y are
different, but the inputs they match individually have significant
overlap, and where they do overlap, I need y to be matched rather than x.
On a related note, when I defined BOOST_SPIRIT_DEBUG before #including the
core, and specified BOOST_SPIRIT_DEBUG_RULE(test); in my grammar I
received the following error message using g++-3.2.2 on linux-i686:
test_grammar.hpp:45: ISO C++ forbits declaration of `get_node_registry'
with no type
test_grammar.hpp:45: invalid use of `::'
test_grammar.hpp:45: syntax error before `.' token
Any idea what I might be doing wrong?
Also, please let me know if I should be asking this on a spriit-specific
list rather than boost's.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk