Skip to content

Commit 78b233e

Browse files
committed
[js] Work around for unicode issue
MoarVM uses NFG while the js backend doesn't do it. The js backend is cross compiling so that causes a problem with our hardcoded as string literals lists of characters. Work around it using nqp::chr(0x....).
1 parent 2bfafb8 commit 78b233e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/HLL/Grammar.nqp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ grammar HLL::Grammar {
4141
"\x[FE59]\x[FE5A]\x[FE5B]\x[FE5C]\x[FE5D]\x[FE5E]\x[FF08]\x[FF09]\x[FF1C]\x[FF1E]" ~
4242
"\x[FF3B]\x[FF3D]\x[FF5B]\x[FF5D]\x[FF5F]\x[FF60]\x[FF62]\x[FF63]\x[27EE]\x[27EF]" ~
4343
"\x[2E24]\x[2E25]\x[27EC]\x[27ED]\x[2E22]\x[2E23]\x[2E26]\x[2E27]" ~
44+
#?if js
45+
nqp::chr(0x2329) ~ nqp::chr(0x232A) ~
46+
#?endif
4447
"\x[FD3E]\x[FD3F]"; # All brackets have matching Ps/Pe or Pi/Pf except \x[FD3E]\x[FD3F]
4548
# (ORNATE PARENTHESIS), which are allowed since they are RTL Text characters
4649

src/QRegex/P5Regex/Actions.nqp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ class QRegex::P5Regex::Actions is HLL::Actions {
201201

202202
method p5backslash:sym<h>($/) {
203203
make QAST::Regex.new(
204+
#?if js
205+
nqp::chr(0x2000) ~ nqp::chr(0x2001) ~ # HACK workaround for a cross compiling problem
206+
#?endif
204207
"\x[09,20,a0,1680,180e,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,200a,202f,205f,3000]",
205208
:rxtype('enumcharlist'),
206209
:negate($<sym> eq 'H'),
@@ -556,6 +559,9 @@ class QRegex::P5Regex::Actions is HLL::Actions {
556559

557560
method backslash:sym<h>($/) {
558561
my $qast := QAST::Regex.new(
562+
#?if js
563+
nqp::chr(0x2000) ~ nqp::chr(0x2001) ~ # HACK workaround for a cross compiling problem
564+
#?endif
559565
"\x[09,20,a0,1680,180e,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,200a,202f,205f,3000]",
560566
:rxtype('enumcharlist'),
561567
:negate($<sym> eq 'H'),

src/QRegex/P6Regex/Actions.nqp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ class QRegex::P6Regex::Actions is HLL::Actions {
349349
method backslash:sym<h>($/) {
350350

351351
my $qast := QAST::Regex.new(
352+
#?if js
353+
nqp::chr(0x2000) ~ nqp::chr(0x2001) ~ # HACK workaround for a cross compiling problem
354+
#?endif
352355
"\x[09,20,a0,1680,180e,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,200a,202f,205f,3000]",
353356
:rxtype('enumcharlist'),
354357
:negate($<sym> eq 'H'),
@@ -434,6 +437,9 @@ class QRegex::P6Regex::Actions is HLL::Actions {
434437

435438
method cclass_backslash:sym<h>($/) {
436439
my $qast := QAST::Regex.new(
440+
#?if js
441+
nqp::chr(0x2000) ~ nqp::chr(0x2001) ~ # HACK workaround for a cross compiling problem
442+
#?endif
437443
"\x[09,20,a0,1680,180e,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,200a,202f,205f,3000]",
438444
:rxtype('enumcharlist'),
439445
:negate($<sym> eq 'H'),

0 commit comments

Comments
 (0)