summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-01-04 02:27:11 -0800
committerKeith Packard <keithp@keithp.com>2018-01-04 02:27:11 -0800
commitd34f01110d8770ac99556901143a54c3d492cde0 (patch)
tree40bad1c2643a9d85d9750c5a2a788e5c5138c85c
parent243baa14a62e3efe5ae792c73db75f9c2cb86abb (diff)
altos/scheme: Accept more escaped character constants
Allow all those specified in r7rs Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/scheme/ao_scheme_read.c20
-rw-r--r--src/scheme/ao_scheme_read.h5
2 files changed, 13 insertions, 12 deletions
diff --git a/src/scheme/ao_scheme_read.c b/src/scheme/ao_scheme_read.c
index 7d540aa5..f7e95a63 100644
--- a/src/scheme/ao_scheme_read.c
+++ b/src/scheme/ao_scheme_read.c
@@ -110,7 +110,7 @@ static const uint16_t lex_classes[128] = {
PRINTABLE, /* Y */
PRINTABLE, /* Z */
PRINTABLE, /* [ */
- PRINTABLE|BACKSLASH, /* \ */
+ PRINTABLE, /* \ */
PRINTABLE, /* ] */
PRINTABLE, /* ^ */
PRINTABLE, /* _ */
@@ -204,18 +204,20 @@ lex_quoted(void)
lex_class = 0;
c &= 0x7f;
switch (c) {
- case 'n':
- return '\n';
- case 'f':
- return '\f';
+ case 'a':
+ return '\a';
case 'b':
return '\b';
+ case 't':
+ return '\t';
+ case 'n':
+ return '\n';
case 'r':
return '\r';
+ case 'f':
+ return '\f';
case 'v':
return '\v';
- case 't':
- return '\t';
case '0':
case '1':
case '2':
@@ -422,7 +424,7 @@ _lex(void)
if (lex_class & STRINGC) {
for (;;) {
c = lexc();
- if (lex_class & BACKSLASH)
+ if (c == '\\')
c = lex_quoted();
if (lex_class & (STRINGC|ENDOFFILE)) {
end_token();
@@ -636,7 +638,7 @@ ao_scheme_read(void)
v = _ao_scheme_bool_false;
break;
case STRING:
- string = ao_scheme_string_make(token_string);
+ string = ao_scheme_string_new(token_string);
if (string)
v = ao_scheme_string_poly(string);
else
diff --git a/src/scheme/ao_scheme_read.h b/src/scheme/ao_scheme_read.h
index d0b9b36a..209a3a87 100644
--- a/src/scheme/ao_scheme_read.h
+++ b/src/scheme/ao_scheme_read.h
@@ -63,9 +63,8 @@
# define ENDOFFILE 0x0080 /* end of file */
# define COMMENT 0x0100 /* ; */
# define IGNORE 0x0200 /* \0 - ' ' */
-# define BACKSLASH 0x0400 /* \ */
-# define STRINGC 0x0800 /* " */
-# define HEX_LETTER 0x1000 /* a-f A-F */
+# define STRINGC 0x0400 /* " */
+# define HEX_LETTER 0x0800 /* a-f A-F */
# define NOTNAME (STRINGC|COMMENT|ENDOFFILE|WHITE|SPECIAL)
# define INTEGER (DIGIT|SIGN)