2

I have a problem that IDK how to do no_case in spirit X3. There is no_case in Spirit, but when I use it I get:

    // If you get an error no matching function for call to 'as_parser'
    // here, for either p or s, then p or s is not a parser or there is
    // no suitable conversion from p to a parser.

It is possible I am confused and I am trying to mix apples and oranges (qi and x3, for example IDK the difference between x3::parse and qi::parse)

So tl;dr my question is how to make this work:

bool parsed = phrase_parse(first, last, no_case[char_('a')], space);

(without no_case it works)

NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277

1 Answers1

2

Yes, you are likely mixing x3 and qi. Here's the simplest example that works:

Live On Coliru

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

namespace x3 = boost::spirit::x3;

int main() {
    std::string const input = "A";
    auto first = input.begin(), last = input.end();
    bool parsed = x3::phrase_parse(first, last, x3::no_case[x3::char_('a')], x3::space);
    return parsed? 0:1;
}
sehe
  • 374,641
  • 47
  • 450
  • 633
  • yeah, pretty embarrasing, I did not notice no_case exists in x3 namespace and all googling gives the one in qi. Is qi totally superseeded by x3, in other words is it always mistake to mix x3 and qi? – NoSenseEtAl Nov 02 '16 at 04:44
  • 3
    Yes⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ ⁠ – sehe Nov 02 '16 at 08:27