On Mon, May 2, 2011 at 7:18 PM, Hartmut Kaiser
Spirit grammars are still C++ and still obey the default C++ operator preferences. Use this instead:
BOOST_AUTO(fileName, *(char_ - keywordSym));
and it will work.
Hi Hartmut - Thanks for the input. I had tried this precedence before, and during my mucking about I guess I forgot to put the parens back in. In any case, the above production still doesn't work, because it continues parsing until the end of the file... TILT=foobar 1 2... will eat everything. I'm not sure how to make it stop at the end of the line, because I'm using the space-eating parser, which seems to eat whitespace before checking the rules. Additionally, I'm having trouble getting the parsed value into a string. I can get the above example to work like this: BOOST_AUTO(fileName, *((char_ - keywordSym) - qi::digit))[ref(tiltFileName) = _1]); I used digit because I know that a digit will follow the filename, but if the filename contains a digit, of course this will fail. That's one problem. The other problem is that tiltFileName only contains 'r' after parsing. My hunch is that this is because the char_ parser parses one character at a time, so only the last one is there. I tried wrapping the production as (*((char_ - keywordSym)-qi::digit))[...], but now I can't get the code to compile. Any further ideas are much appreciated. Brian