Make use of \u2190 char optional

VS2010 is not capable of compiling source code with chars beyond the
"current code page" reliably.
pull/20/head
hvellyr 8 years ago committed by gck
parent 1e47348daf
commit 546942e389
  1. 8
      peglib.h
  2. 15
      test/test.cc

@ -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"]);

@ -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]")
{

Loading…
Cancel
Save