poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[COMMITTED] pkl-lex.l: accept lower-case b as suffix of integer literals


From: Mohammad-Reza Nabipoor
Subject: [COMMITTED] pkl-lex.l: accept lower-case b as suffix of integer literals
Date: Thu, 1 Sep 2022 17:34:55 +0430

2022-09-01  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>

        * libpoke/pkl-lex.l (IS): Add lower-case b to `IS' definition.
        (Integer literal rule): Accept lower-case b as a valid suffix.
        * doc/learn-poke-language-in-y-minutes.pk: Add a line about integer
        suffixes.
        * testsuite/Makefile.am (EXTRA_DIST): Update.
        * testsuite/poke.pkl/integers-8.pk: New test.
        * testsuite/poke.pkl/integers-9.pk: Likewise.
        * testsuite/poke.pkl/integers-10.pk: Likewise.
---

Hello Jose,

On Tue, Aug 16, 2022 at 12:27:02PM +0200, Jose E. Marchesi wrote:
> This is OK for master, provided you include an update for the manual and
> also a test.
>
> Maybe also update doc/learn-poke-language-in-y-minutes.pk?
>

Changes:
  - Added a line to doc/learn-poke-language-in-y-minutes.pk
  - Added 3 tests
  
The documentation is already there :)
See Integer Literals section of manual!

Regards,
Mohammad-Reza


 ChangeLog                               | 11 +++++++++++
 doc/learn-poke-language-in-y-minutes.pk |  3 +++
 libpoke/pkl-lex.l                       | 11 ++++++-----
 testsuite/Makefile.am                   |  3 +++
 testsuite/poke.pkl/integers-10.pk       |  4 ++++
 testsuite/poke.pkl/integers-8.pk        |  4 ++++
 testsuite/poke.pkl/integers-9.pk        |  4 ++++
 7 files changed, 35 insertions(+), 5 deletions(-)
 create mode 100644 testsuite/poke.pkl/integers-10.pk
 create mode 100644 testsuite/poke.pkl/integers-8.pk
 create mode 100644 testsuite/poke.pkl/integers-9.pk

diff --git a/ChangeLog b/ChangeLog
index ef9187f5..89dc0b73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-09-01  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
+
+       * libpoke/pkl-lex.l (IS): Add lower-case b to `IS' definition.
+       (Integer literal rule): Accept lower-case b as a valid suffix.
+       * doc/learn-poke-language-in-y-minutes.pk: Add a line about integer
+       suffixes.
+       * testsuite/Makefile.am (EXTRA_DIST): Update.
+       * testsuite/poke.pkl/integers-8.pk: New test.
+       * testsuite/poke.pkl/integers-9.pk: Likewise.
+       * testsuite/poke.pkl/integers-10.pk: Likewise.
+
 2022-07-25  Jose E. Marchesi  <jemarch@gnu.org>
 
        * configure.ac: Bump version to 2.4.
diff --git a/doc/learn-poke-language-in-y-minutes.pk 
b/doc/learn-poke-language-in-y-minutes.pk
index 832ad4cb..4345dfcd 100644
--- a/doc/learn-poke-language-in-y-minutes.pk
+++ b/doc/learn-poke-language-in-y-minutes.pk
@@ -103,6 +103,9 @@ var ui64 = 7UL;    /* unsigned long (64-bit) */
 var long_decimal = 100_000_000;
 var long_hexadecimal = 0x1122_aabb_ccdd_eeff;
 
+/* NOTE Integer suffixes are case-insensitive. 1B == 1b, 10UH == 10uh, etc.
+ */
+
 /* Operations on integer values */
 
 /* Arithmetic */
diff --git a/libpoke/pkl-lex.l b/libpoke/pkl-lex.l
index 78f1ce1d..522f9c37 100644
--- a/libpoke/pkl-lex.l
+++ b/libpoke/pkl-lex.l
@@ -143,7 +143,7 @@ HEXCST                   0[xX][0-9a-fA-F][0-9a-fA-F_]*
 BINCST                   0[bB][01][01_]*
 OCTCST             0[oO][0-7_]*
 DECCST             [0-9][0-9_]*
-IS                   ((u|U)|(u|U)?(l|L|B|h|H|n|N)|(l|L|B|h|H|n|N)(u|U))
+IS                   ((u|U)|(u|U)?(l|L|b|B|h|H|n|N)|(l|L|b|B|h|H|n|N)(u|U))
 
 L [a-zA-Z_]
 D [0-9]
@@ -608,15 +608,16 @@ S ::
 
   width = 0;
   if (*end == 'l' || *end == 'L'
-      || ((*end != '\0') && ((*(end + 1) == 'l' || *(end + 1) == 'L'))))
+      || ((*end != '\0') && (*(end + 1) == 'l' || *(end + 1) == 'L')))
     width = 64;
   else  if (*end == 'h' || *end == 'H'
-      || ((*end != '\0') && ((*(end + 1) == 'h' || *(end + 1) == 'H'))))
+      || ((*end != '\0') && (*(end + 1) == 'h' || *(end + 1) == 'H')))
     width = 16;
-  else  if (*end == 'B' || ((*end != '\0') && *(end + 1) == 'B'))
+  else  if (*end == 'b' || *end == 'B'
+      || ((*end != '\0') && (*(end + 1) == 'b' || *(end + 1) == 'B')))
     width = 8;
   else if (*end == 'n' || *end == 'N'
-      || ((*end != '\0') && ((*(end + 1) == 'n' || *(end + 1) == 'N'))))
+      || ((*end != '\0') && (*(end + 1) == 'n' || *(end + 1) == 'N')))
     width = 4;
 
   /* If not specified with the 'l' or 'L' suffix, the type of the
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 0a4e9410..10eb14ed 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1415,6 +1415,9 @@ EXTRA_DIST = \
   poke.pkl/integers-5.pk \
   poke.pkl/integers-6.pk \
   poke.pkl/integers-7.pk \
+  poke.pkl/integers-8.pk \
+  poke.pkl/integers-9.pk \
+  poke.pkl/integers-10.pk \
   poke.pkl/integers-diag-1.pk \
   poke.pkl/integers-diag-2.pk \
   poke.pkl/iobias-1.pk \
diff --git a/testsuite/poke.pkl/integers-10.pk 
b/testsuite/poke.pkl/integers-10.pk
new file mode 100644
index 00000000..3f02cf13
--- /dev/null
+++ b/testsuite/poke.pkl/integers-10.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command { 9bu } } */
+/* { dg-output 9UB } */
diff --git a/testsuite/poke.pkl/integers-8.pk b/testsuite/poke.pkl/integers-8.pk
new file mode 100644
index 00000000..f5284f50
--- /dev/null
+++ b/testsuite/poke.pkl/integers-8.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command { 6b } } */
+/* { dg-output 6B } */
diff --git a/testsuite/poke.pkl/integers-9.pk b/testsuite/poke.pkl/integers-9.pk
new file mode 100644
index 00000000..824e23ed
--- /dev/null
+++ b/testsuite/poke.pkl/integers-9.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command { 6ub } } */
+/* { dg-output 6UB } */
-- 
2.37.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]