From 36ce6edde76db159bd2f8fa527bf45257e3765fb Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Thu, 15 Feb 2024 20:41:56 +0000 Subject: [PATCH] Initial implementation of xor logical operator --- perly.act | 4 ++-- perly.h | 2 +- perly.tab | 2 +- perly.y | 2 +- toke.c | 11 +++++++++++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/perly.act b/perly.act index 8899d314e005e..2c544f754bf70 100644 --- a/perly.act +++ b/perly.act @@ -1554,7 +1554,7 @@ case 2: case 199: #line 1250 "perly.y" - { (yyval.opval) = newLOGOP(OP_OR, 0, (ps[-2].val.opval), (ps[0].val.opval)); } + { (yyval.opval) = newLOGOP((ps[-1].val.ival), 0, (ps[-2].val.opval), (ps[0].val.opval)); } break; @@ -2354,6 +2354,6 @@ case 2: /* Generated from: - * ae786f28e8bc303471bcc03fc82e93a348d603252cc8c164a96cc0c26af78217 perly.y + * d200edcf6b5ba783b2b4e34928c5787fcab506e14d318042f4e46dee90ba0898 perly.y * acf1cbfd2545faeaaa58b1cf0cf9d7f98b5be0752eb7a54528ef904a9e2e1ca7 regen_perly.pl * ex: set ro ft=c: */ diff --git a/perly.h b/perly.h index 751b13bb42882..e878f0f67b997 100644 --- a/perly.h +++ b/perly.h @@ -236,6 +236,6 @@ int yyparse (void); /* Generated from: - * ae786f28e8bc303471bcc03fc82e93a348d603252cc8c164a96cc0c26af78217 perly.y + * d200edcf6b5ba783b2b4e34928c5787fcab506e14d318042f4e46dee90ba0898 perly.y * acf1cbfd2545faeaaa58b1cf0cf9d7f98b5be0752eb7a54528ef904a9e2e1ca7 regen_perly.pl * ex: set ro ft=c: */ diff --git a/perly.tab b/perly.tab index 77d4a49bbf1b9..4c5844d210506 100644 --- a/perly.tab +++ b/perly.tab @@ -1336,6 +1336,6 @@ static const toketypes yy_type_tab[] = }; /* Generated from: - * ae786f28e8bc303471bcc03fc82e93a348d603252cc8c164a96cc0c26af78217 perly.y + * d200edcf6b5ba783b2b4e34928c5787fcab506e14d318042f4e46dee90ba0898 perly.y * acf1cbfd2545faeaaa58b1cf0cf9d7f98b5be0752eb7a54528ef904a9e2e1ca7 regen_perly.pl * ex: set ro ft=c: */ diff --git a/perly.y b/perly.y index e16aa0767ba72..ac3102e13c483 100644 --- a/perly.y +++ b/perly.y @@ -1247,7 +1247,7 @@ termbinop: term[lhs] PLUGIN_HIGH_OP[op] term[rhs] | term[lhs] PLUGIN_LOGICAL_AND_OP[op] term[rhs] { $$ = build_infix_plugin($lhs, $rhs, $op); } | term[lhs] OROR term[rhs] /* $x || $y */ - { $$ = newLOGOP(OP_OR, 0, $lhs, $rhs); } + { $$ = newLOGOP($OROR, 0, $lhs, $rhs); } | term[lhs] PLUGIN_LOGICAL_OR_OP[op] term[rhs] { $$ = build_infix_plugin($lhs, $rhs, $op); } | term[lhs] DORDOR term[rhs] /* $x // $y */ diff --git a/toke.c b/toke.c index dd3bbdd0b6801..5f71139274989 100644 --- a/toke.c +++ b/toke.c @@ -6099,6 +6099,16 @@ yyl_caret(pTHX_ char *s) { char *d = s; const bool bof = cBOOL(FEATURE_BITWISE_IS_ENABLED); + if (s[1] == '^') { + s += 2; + if (!PL_lex_allbrackets && PL_lex_fakeeof >= + (*s == '=' ? LEX_FAKEEOF_ASSIGN : LEX_FAKEEOF_LOGIC)) { + s -= 2; + TOKEN(0); + } + pl_yylval.ival = OP_XOR; + OPERATOR(OROR); + } if (bof && s[1] == '.') s++; if (!PL_lex_allbrackets && PL_lex_fakeeof >= @@ -6618,6 +6628,7 @@ yyl_verticalbar(pTHX_ char *s) s -= 2; TOKEN(0); } + pl_yylval.ival = OP_OR; AOPERATOR(OROR); }