[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] pkl: fix recognition of token 0[bB] in the lexer
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] pkl: fix recognition of token 0[bB] in the lexer |
Date: |
Thu, 26 Jan 2023 01:11:00 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
I installed this patch in both master and maint/poke-3.
2023-01-26 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-lex.l (pkl_lex_get_base): Handle 0[Bb] literals
properly.
* testsuite/poke.pkl/integers-11.pk: New test.
* testsuite/poke.pkl/integers-12.pk: Likewise.
* testsuite/Makefile.am (EXTRA_DIST): Add new tests.
---
ChangeLog | 8 ++++++++
libpoke/pkl-lex.l | 5 ++++-
testsuite/Makefile.am | 2 ++
testsuite/poke.pkl/integers-11.pk | 4 ++++
testsuite/poke.pkl/integers-12.pk | 4 ++++
5 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 testsuite/poke.pkl/integers-11.pk
create mode 100644 testsuite/poke.pkl/integers-12.pk
diff --git a/ChangeLog b/ChangeLog
index 47636ce0..4062f7d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-01-26 Jose E. Marchesi <jemarch@gnu.org>
+
+ * libpoke/pkl-lex.l (pkl_lex_get_base): Handle 0[Bb] literals
+ properly.
+ * testsuite/poke.pkl/integers-11.pk: New test.
+ * testsuite/poke.pkl/integers-12.pk: Likewise.
+ * testsuite/Makefile.am (EXTRA_DIST): Add new tests.
+
2023-01-25 Jose E. Marchesi <jemarch@gnu.org>
* configure.ac: Bump version number to 3.0.
diff --git a/libpoke/pkl-lex.l b/libpoke/pkl-lex.l
index 9e0cd7aa..d77fb808 100644
--- a/libpoke/pkl-lex.l
+++ b/libpoke/pkl-lex.l
@@ -116,8 +116,11 @@ pkl_lex_get_base (const char *str, int *offset)
base = 16;
*offset = 2;
}
- else if (str[1] == 'b' || str[1] == 'B')
+ else if ((str[1] == 'b' || str[1] == 'B')
+ && (str[2] != '\0'))
{
+ /* Note the above check for \0 is to distinguish these two
+ cases: 0[bB][0-1]+ and 0[bB] */
base = 2;
*offset = 2;
}
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 885dcb0d..0411b9a5 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1659,6 +1659,8 @@ EXTRA_DIST = \
poke.pkl/integers-8.pk \
poke.pkl/integers-9.pk \
poke.pkl/integers-10.pk \
+ poke.pkl/integers-11.pk \
+ poke.pkl/integers-12.pk \
poke.pkl/integers-diag-1.pk \
poke.pkl/integers-diag-2.pk \
poke.pkl/integers-diag-3.pk \
diff --git a/testsuite/poke.pkl/integers-11.pk
b/testsuite/poke.pkl/integers-11.pk
new file mode 100644
index 00000000..f20d76bf
--- /dev/null
+++ b/testsuite/poke.pkl/integers-11.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {0B'size/#b} } */
+/* { dg-output {8UL} } */
diff --git a/testsuite/poke.pkl/integers-12.pk
b/testsuite/poke.pkl/integers-12.pk
new file mode 100644
index 00000000..297e350c
--- /dev/null
+++ b/testsuite/poke.pkl/integers-12.pk
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+
+/* { dg-command {0b'size/#b} } */
+/* { dg-output {8UL} } */
--
2.30.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] pkl: fix recognition of token 0[bB] in the lexer,
Jose E. Marchesi <=