boostorg / spirit

Boost.org spirit module
http://boost.org/libs/spirit
392 stars 161 forks source link

x3::unicode::lit does not take single unicode character literal #573

Open saki7 opened 4 years ago

saki7 commented 4 years ago

These two both work:

// defined in boost/spirit/home/x3/string/literal_string.hpp
auto const dollar_def = x3::standard::lit("$"); // double quotes

// `lit` delegates to: boost/spirit/home/x3/char/char.hpp
auto const dollar_def = x3::standard::lit('$'); // single quotes

For unicode characters, the single quoted one won't work:

// defined in boost/spirit/home/x3/string/literal_string.hpp
auto const dollar_def = x3::unicode::lit(U"$"); // double quotes

// fails to compile
auto const dollar_def = x3::unicode::lit(U'$'); // single quotes

It seems like the single char lit interfaces for unicode chars are missing in char.hpp.

I'm currently using U"double quotes" for single letter grammars, which is obviously against the optimization.

saki7 commented 4 years ago

Dear maintainers: I'd like to PR if extending char.hpp is the correct approach. Please give me the green light.

Kojoley commented 4 years ago

Just open a PR if you have a fix. Do not forget about tests.