Odd behaviour of char_ parser?

Jay Pipes <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
Hi!

I am hoping that I just don't understand the internals of the char_ 
parser and not that this is some sort of bug (unlikely).

Anyway, I want to parse a string "`foo`" (backticks surrounding the word 
foo). Simple enough, right?

I have a parser that looks like this:

auto const backtick_ascii_foo = lexeme[
     '`' >> *char_("fo") >> '`'
];

The above works perfectly fine and passing the string "`foo`" to 
x3::phrase_parse() along with the above grammar indeed succeeds in parsing.

However, if I change the char_("fo") to contain the code points for "f" 
and "o" like so:

auto const backtick_code_point_foo = lexeme[
     '`' >> *char_("\x60\x6f") >> '`'
];

the string "`foo`" no longer parses.

I'm not sure why and it has me a bit stumped :) Hoping someone can shed 
some light on this.

I've pastebin'd some code that shows the issue here:

http://pastebin.com/5pcrgpx6

$ g++ -I. -I/usr/local/include -std=gnu++14 -o testing.cc.o -c testing.cc
$ g++ testing.cc.o -o testing
$ ./testing
Parsing `foo` with name_code_point parser: 0
Parsing `foo` with name_ascii parser: 1

Any help or insights would be greatly appreciated. Thanks in advance!
-jay

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.