[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] pkl,testsuite: Support for `**=` operator
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH] pkl,testsuite: Support for `**=` operator |
Date: |
Tue, 24 Nov 2020 01:19:35 +0330 |
2020-11-24 Mohammad-Reza Nabipoor <m.nabipoor@yahoo.com>
* libpoke/pkl-ops.def: Remove unused definitions.
* libpoke/pkl-lex.l: New token: `POWA`.
* libpoke/pkl-tab.y: Use `POWA` in `ass_exp_op` rule.
* testsuite/poke.pkl/powa-int-1.pk: New test.
* testsuite/poke.pkl/powa-offset-1.pk: Likewise.
* testsuite/Makefile.am (EXTRA_DIST): Add new tests.
---
ChangeLog | 9 +++++++++
libpoke/pkl-lex.l | 1 +
libpoke/pkl-ops.def | 15 ---------------
libpoke/pkl-tab.y | 4 +++-
testsuite/Makefile.am | 2 ++
testsuite/poke.pkl/powa-int-1.pk | 7 +++++++
testsuite/poke.pkl/powa-offset-1.pk | 7 +++++++
7 files changed, 29 insertions(+), 16 deletions(-)
create mode 100644 testsuite/poke.pkl/powa-int-1.pk
create mode 100644 testsuite/poke.pkl/powa-offset-1.pk
diff --git a/ChangeLog b/ChangeLog
index 96921413..b3c53a8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-11-24 Mohammad-Reza Nabipoor <m.nabipoor@yahoo.com>
+
+ * libpoke/pkl-ops.def: Remove unused definitions.
+ * libpoke/pkl-lex.l: New token: `POWA`.
+ * libpoke/pkl-tab.y: Use `POWA` in `ass_exp_op` rule.
+ * testsuite/poke.pkl/powa-int-1.pk: New test.
+ * testsuite/poke.pkl/powa-offset-1.pk: Likewise.
+ * testsuite/Makefile.am (EXTRA_DIST): Add new tests.
+
2020-11-23 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-tab.y (ass_exp_op): New rule.
diff --git a/libpoke/pkl-lex.l b/libpoke/pkl-lex.l
index bd8fc4f3..a2ea3b95 100644
--- a/libpoke/pkl-lex.l
+++ b/libpoke/pkl-lex.l
@@ -256,6 +256,7 @@ S ::
"..." { return THREEDOTS; }
"+:" { return RANGEA; }
+"**=" { return POWA; }
"*=" { return MULA; }
"/=" { return DIVA; }
"%=" { return MODA; }
diff --git a/libpoke/pkl-ops.def b/libpoke/pkl-ops.def
index 6ae08215..7d934ccf 100644
--- a/libpoke/pkl-ops.def
+++ b/libpoke/pkl-ops.def
@@ -60,21 +60,6 @@ PKL_DEF_OP (PKL_AST_OP_BNOT, "BNOT")
PKL_DEF_OP (PKL_AST_OP_NOT, "NOT")
PKL_DEF_OP (PKL_AST_OP_UNMAP, "UNMAP")
-#if 0
-/* Assign operators. */
-PKL_DEF_OP (PKL_AST_OP_ASSIGN, "ASSIGN")
-PKL_DEF_OP (PKL_AST_OP_MULA, "MULA")
-PKL_DEF_OP (PKL_AST_OP_DIVA, "DIVA")
-PKL_DEF_OP (PKL_AST_OP_MODA, "MODA")
-PKL_DEF_OP (PKL_AST_OP_ADDA, "ADDA")
-PKL_DEF_OP (PKL_AST_OP_SUBA, "SUBA")
-PKL_DEF_OP (PKL_AST_OP_SLA, "SLA")
-PKL_DEF_OP (PKL_AST_OP_SRA, "SRA")
-PKL_DEF_OP (PKL_AST_OP_BANDA, "BANDA")
-PKL_DEF_OP (PKL_AST_OP_XORA, "XORA")
-PKL_DEF_OP (PKL_AST_OP_IORA, "IORA")
-#endif
-
/*
Local variables:
mode:c
diff --git a/libpoke/pkl-tab.y b/libpoke/pkl-tab.y
index 21599dc7..69686e76 100644
--- a/libpoke/pkl-tab.y
+++ b/libpoke/pkl-tab.y
@@ -344,6 +344,7 @@ token <integer> UNION _("keyword `union'")
/* Opcodes. */
+%token <opcode> POWA _("power-and-assign operator")
%token <opcode> MULA _("multiply-and-assign operator")
%token <opcode> DIVA _("divide-and-assing operator")
%token <opcode> MODA _("modulus-and-assign operator")
@@ -1854,7 +1855,8 @@ stmt_decl_list:
;
ass_exp_op:
- MULA { $$ = PKL_AST_OP_MUL; }
+ POWA { $$ = PKL_AST_OP_POW; }
+ | MULA { $$ = PKL_AST_OP_MUL; }
| DIVA { $$ = PKL_AST_OP_DIV; }
| MODA { $$ = PKL_AST_OP_MOD; }
| ADDA { $$ = PKL_AST_OP_ADD; }
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 94d56f7a..de116082 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1235,6 +1235,8 @@ EXTRA_DIST = \
poke.pkl/pow-offsets-1.pk \
poke.pkl/pow-offsets-2.pk \
poke.pkl/pow-offsets-3.pk \
+ poke.pkl/powa-int-1.pk \
+ poke.pkl/powa-offset-1.pk \
poke.pkl/preincr-1.pk \
poke.pkl/predecr-offset-1.pk \
poke.pkl/predecr-field-1.pk \
diff --git a/testsuite/poke.pkl/powa-int-1.pk b/testsuite/poke.pkl/powa-int-1.pk
new file mode 100644
index 00000000..fa6bfc5b
--- /dev/null
+++ b/testsuite/poke.pkl/powa-int-1.pk
@@ -0,0 +1,7 @@
+/* { dg-do run } */
+
+var foo = 10;
+
+/* { dg-command { foo **= 3 } } */
+/* { dg-command { foo } } */
+/* { dg-output "1000" } */
diff --git a/testsuite/poke.pkl/powa-offset-1.pk
b/testsuite/poke.pkl/powa-offset-1.pk
new file mode 100644
index 00000000..2c090d30
--- /dev/null
+++ b/testsuite/poke.pkl/powa-offset-1.pk
@@ -0,0 +1,7 @@
+/* { dg-do run } */
+
+var foo = 10#B;
+
+/* { dg-command { foo **= 3 } } */
+/* { dg-command { foo } } */
+/* { dg-output "1000#B" } */
--
2.29.2
- [PATCH] pkl,testsuite: Support for `**=` operator,
Mohammad-Reza Nabipoor <=