[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Add support for \\ as a char.
From: |
John Darrington |
Subject: |
[PATCH] Add support for \\ as a char. |
Date: |
Wed, 11 Dec 2019 10:48:04 +0100 |
* src/pkl-lex. (CHAR): Accept \\ as a CHAR token.
* testsuite/poke.pkl/chars.pk: Add new test.
* doc/poke.texi (Characters): Document new escape sequence.
---
ChangeLog | 6 ++++++
doc/poke.texi | 3 +++
src/pkl-lex.l | 5 ++++-
testsuite/poke.pkl/chars.pk | 3 +++
4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index e4d4867..76e82f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-12-08 John Darrington <address@hidden>
+
+ * src/pkl-lex. (CHAR): Accept \\ as a CHAR token.
+ * testsuite/poke.pkl/chars.pk: Add new test.
+ * doc/poke.texi (Characters): Document new escape sequence.
+
2019-12-01 John Darrington <address@hidden>
* doc/poke.texi (Offset Literals): Change the example to agree with
the text.
diff --git a/doc/poke.texi b/doc/poke.texi
index 8ec382e..5b353f5 100644
--- a/doc/poke.texi
+++ b/doc/poke.texi
@@ -968,6 +968,8 @@ allowed sequences are:
New-line character (ASCII 012).
@item \t
Tab character (ASCII 011).
+@item \\
+The backslash character.
@item \[0-9][0-9]?[0-9]?
Character whose ASCII code is the specified number, in octal.
@end table
@@ -978,6 +980,7 @@ Examples:
'o'
'\n'
'\t'
+'\\'
'\0'
@end example
diff --git a/src/pkl-lex.l b/src/pkl-lex.l
index d31f2d3..31895b1 100644
--- a/src/pkl-lex.l
+++ b/src/pkl-lex.l
@@ -123,7 +123,7 @@ NEWLINE \n
BLANK [ \t]
LETTER [a-zA-Z]
FIELD_NAME {LETTER}[a-zA-Z0-9_]*
-CHAR '(.|\\[nt]|\\[0-7]|\\[0-7][0-7]|\\[0-7][0-7][0-7])'
+CHAR '(.|\\[nt\\]|\\[0-7]|\\[0-7][0-7]|\\[0-7][0-7][0-7])'
STRING \"([^"]|\\(.|\n))*\"
HEXCST 0[xX][0-9a-fA-F][0-9a-fA-F_]*
BINCST 0[bB][01][01_]*
@@ -410,6 +410,9 @@ D [0-9]
case 't':
value = '\t';
break;
+ case '\\':
+ value = '\\';
+ break;
default:
/* To avoid compiler warnings. */
value = 0;
diff --git a/testsuite/poke.pkl/chars.pk b/testsuite/poke.pkl/chars.pk
index b209b9d..d039e76 100644
--- a/testsuite/poke.pkl/chars.pk
+++ b/testsuite/poke.pkl/chars.pk
@@ -20,3 +20,6 @@
/* { dg-command { '\t' } } */
/* { dg-output "\n9UB" } */
+
+/* { dg-command { '\\' } } */
+/* { dg-output "\n92UB" } */
--
2.11.0
- [PATCH] Add support for \\ as a char.,
John Darrington <=