Make use of \u2190 char optional

VS2010 is not capable of compiling source code with chars beyond the
"current code page" reliably.
This commit is contained in:
hvellyr 2016-05-29 23:11:38 +02:00 committed by gck
parent 1e47348daf
commit 546942e389
2 changed files with 22 additions and 1 deletions

View File

@ -35,6 +35,10 @@
#endif
#endif
// define if the compiler doesn't support unicode characters reliably in the
// source code
//#define PEGLIB_NO_UNICODE_CHARS
namespace peg {
extern void* enabler;
@ -1813,7 +1817,11 @@ private:
seq(lit("\\x"), cls("0-9a-fA-F"), opt(cls("0-9a-fA-F"))),
seq(npd(chr('\\')), dot()));
#if !defined(PEGLIB_NO_UNICODE_CHARS)
g["LEFTARROW"] <= seq(cho(lit("<-"), lit("")), g["Spacing"]);
#else
g["LEFTARROW"] <= seq(lit("<-"), g["Spacing"]);
#endif
~g["SLASH"] <= seq(chr('/'), g["Spacing"]);
g["AND"] <= seq(chr('&'), g["Spacing"]);
g["NOT"] <= seq(chr('!'), g["Spacing"]);

View File

@ -5,7 +5,8 @@
#include <peglib.h>
#include <iostream>
TEST_CASE("Simple syntax test", "[general]")
#if !defined(PEGLIB_NO_UNICODE_CHARS)
TEST_CASE("Simple syntax test (with unicode)", "[general]")
{
peg::parser parser(
" ROOT ← _ "
@ -15,6 +16,18 @@ TEST_CASE("Simple syntax test", "[general]")
bool ret = parser;
REQUIRE(ret == true);
}
#endif
TEST_CASE("Simple syntax test", "[general]")
{
peg::parser parser(
" ROOT <- _ "
" _ <- ' ' "
);
bool ret = parser;
REQUIRE(ret == true);
}
TEST_CASE("Empty syntax test", "[general]")
{