From cb0c0a6144346521d6cf3b02703ba15f67b9b4f3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 25 Feb 2012 15:51:43 -0800 Subject: * parser.l (num_esc): Skip octal indicator 'o' if present. This is needed for character constants. (CHRLIT): Fix broken hex constants, being treated as octal. * txr.1: Document octal character constants. --- ChangeLog | 8 ++++++++ parser.l | 4 +++- txr.1 | 7 ++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42165e0c..76ce0d5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-02-25 Kaz Kylheku + + * parser.l (num_esc): Skip octal indicator 'o' if present. + This is needed for character constants. + (CHRLIT): Fix broken hex constants, being treated as octal. + + * txr.1: Document octal character constants. + 2012-02-25 Kaz Kylheku Version 58 diff --git a/parser.l b/parser.l index 3c09aabc..a53f8514 100644 --- a/parser.l +++ b/parser.l @@ -134,6 +134,8 @@ static wchar_t num_esc(char *num) yyerror("too many digits in hex character escape"); return strtol(num + 1, 0, 16); } else { + if (num[0] == 'o') + num++; if (strlen(num) > 8) yyerror("too many digits in octal character escape"); return strtol(num, 0, 8); @@ -609,7 +611,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} } (x{HEX}+|o{OCT}+) { - yylval.chr = num_esc(yytext+1); + yylval.chr = num_esc(yytext); return LITCHAR; } diff --git a/txr.1 b/txr.1 index 7adeee9b..275a6e8a 100644 --- a/txr.1 +++ b/txr.1 @@ -1033,9 +1033,10 @@ useful for labeling information and situations. Character literals are introduced by the #\e syntax, which is either followed by a character name, the letter x followed by hex digits, -or a single character. Valid character names are: nul, alarm, backspace, tab, -linefeed, newline, vtab, page, return, esc, space. This convention -for character literals is similar to that of the Scheme language. +the letter o followed by octal digits, or a single character. Valid character +names are: nul, alarm, backspace, tab, linefeed, newline, vtab, page, return, +esc, space. This convention for character literals is similar to that of the +Scheme language. .SS String Literals -- cgit v1.2.3