From cdc64fd7a30d68dbd930ded963a804089821d08e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 27 Jan 2012 22:55:14 -0800 Subject: * parser.l: Support hex and octal escapes in string and quasiliterals, as the documentation says. Also support an optional trailing ; delimiter in hex escapes. * txr.1: Documented. --- ChangeLog | 8 ++++++++ parser.l | 5 +++++ txr.1 | 9 +++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f2d8d79..7eef7d0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-01-27 Kaz Kylheku + + * parser.l: Support hex and octal escapes in string and quasiliterals, + as the documentation says. Also support an optional trailing ; + delimiter in hex escapes. + + * txr.1: Documented. + 2012-01-27 Kaz Kylheku * txr.vim: Properly show @[...] inside quasiliteral. diff --git a/parser.l b/parser.l index d9883e6c..5ef544e1 100644 --- a/parser.l +++ b/parser.l @@ -584,6 +584,11 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} lineno++; } +[\\](x{HEX}+;?|o{OCT}+) { + yylval.chr = num_esc(yytext+1); + return LITCHAR; + } + (x{HEX}+|o{OCT}+) { yylval.chr = num_esc(yytext); return LITCHAR; diff --git a/txr.1 b/txr.1 index 54d46384..ea53026f 100644 --- a/txr.1 +++ b/txr.1 @@ -1034,8 +1034,13 @@ for character literals is similar to that of the Scheme language. String literals are delimited by double respectively, and may not span multiple lines. A double quote within a string literal is encoded using \e" and a backslash is encoded as \e\e. Backslash escapes like \en and \et -are recognized, as are hexadecimal escapes like \exFF and octal -escapes like \e123. +are recognized, as are hexadecimal escapes like \exFF or \exxabc and octal +escapes like \e123. Ambiguity between a hex escape and subsequent +text can be resolved by using trailing semicolon delimiter: "\exabc;d" is a +string consisting of the character U+0ABC followed by "d". The semicolon +delimiter disappears. To write a literal semicolon immediately after a hex +escape, write two semicolons, the first of which will be interpreted as a +delimiter. Thus, "\ex21;;" represents "!;". .SS String Quasiliterals -- cgit v1.2.3