New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unicode charset #504
Unicode charset #504
Conversation
Looks good. I'll study this as soon as I fix the (unrelated) failing tests on Visual Studio. |
One comment ^^, otherwise it looks good. I just fixed the (unrelated) VS failing test. |
test/x3/char_set.cpp
Outdated
@@ -0,0 +1,89 @@ | |||
#define BOOST_SPIRIT_X3_UNICODE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need a copyright notice at the top with the Boost license. See other files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!
@@ -93,42 +93,63 @@ namespace boost { namespace spirit { namespace x3 { namespace traits | |||
template <> | |||
struct char_type_of<wchar_t> : mpl::identity<wchar_t> {}; | |||
|
|||
template <> | |||
struct char_type_of<char32_t> : mpl::identity<char32_t> {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am inclined towards simplifying and generalizing the char_type_of
instead because there are more char types and soon or later the question will rise again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am inclined towards simplifying and generalizing the
char_type_of
instead because there are more char types and soon or later the question will rise again.
Makes sense. I'd love to see some ideas in code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #507
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool, that PR obsoletes mine then, no? I'm fine with that. Less code maintenance in general is better.
We can still keep the small tests that I added though as those still have some value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can still keep the small tests that I added though as those still have some value.
Absolutely. I just merged #507. Could you please do a final tweak on this PR to deal the changes? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, took a big of git magic to get there but I managed to condense my PR down to 1 commit that just updates the test files.
test/x3/char_set.cpp
Outdated
// ascii | ||
{ | ||
using namespace boost::spirit::x3; | ||
using char_set = char_set<boost::spirit::char_encoding::ascii>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ain't we already have those tests?
char_set
is just an underlying parser of char_("bla")
if you did not know it https://wandbox.org/permlink/euLu4sbtPOFKnxBg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ain't we already have those tests?
Good question! I was thinking about that actually. Was it in char1.cpp? Perhaps we can just augment those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, Kojoley is correct.
… if you did not know it
At the time, I didn't. You are correct, the ASCII tests are repetitious in this case.
Should I simply move the Unicode tests here to the char1.cpp test file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the time, I didn't. You are correct, the ASCII tests are repetitious in this case.
Should I simply move the Unicode tests here to the char1.cpp test file?
Yes please :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
For some reason, the Travis CI link is showing the wrong build job. This is the correct one that passes for the latest changes: |
We should be good. |
Merged. Many thanks for the splendid PR. |
This pull request gives X3 Unicode literal support for its
char_set<boost::spirit::char_encoding::unicode>
. This passively enablesboost::spirit::x3::unicode::char_
to now support string literals such as:U"hello, \u20ac!"
.This PR also extends the X3
test
utility to work withboost::basic_string_view
as well.