Quantcast

Odd behaviour of char_ parser?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Odd behaviour of char_ parser?

Jay Pipes-2
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
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd behaviour of char_ parser?

Mike Gresens
This post was updated on .
Hi,

"fo" should be "\x66\x6f".

Best regards,
Mike...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd behaviour of char_ parser?

Jay Pipes-2
On 12/13/2016 02:03 AM, Mike Gresens wrote:
> Hi,
>
> "fo" should be "\x66\x6f".

It's the "fo" parser that works. The one with the code points is the one
that doesn't parse.

Best,
-jay

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd behaviour of char_ parser?

Mikael Asplund
What Mike's saying is that you have made a mistake translating the character f into a code point... your example says:

"\x60\x6f"   which is not the same as "fo", but instead "`o".  You should use "\x66\x6f", and it should work.

  /Mikael

-----Original Message-----
From: Jay Pipes [mailto:[hidden email]]
Sent: Tuesday, December 13, 2016 13:53
To: [hidden email]
Subject: Re: [Spirit-general] Odd behaviour of char_ parser?

On 12/13/2016 02:03 AM, Mike Gresens wrote:
> Hi,
>
> "fo" should be "\x66\x6f".

It's the "fo" parser that works. The one with the code points is the one that doesn't parse.

Best,
-jay

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd behaviour of char_ parser?

Jay Pipes-2
On 12/13/2016 08:00 AM, Mikael Asplund wrote:
> What Mike's saying is that you have made a mistake translating the character f into a code point... your example says:
>
> "\x60\x6f"   which is not the same as "fo", but instead "`o".  You should use "\x66\x6f", and it should work.

Doh! That was it. Sorry for the noise!

Best,
-jay

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Loading...