diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-11-15 14:29:34 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-11-15 14:29:34 -0800 |
commit | b6551fda77163f74983688409aaf0c13c8186bec (patch) | |
tree | 690b7abd40236f6ef5e168e84a0a4c6eeeb2d2c2 /txr.1 | |
parent | 9ae8fe9b48cd8e56816225e467f8882c8313d876 (diff) | |
download | txr-b6551fda77163f74983688409aaf0c13c8186bec.tar.gz txr-b6551fda77163f74983688409aaf0c13c8186bec.tar.bz2 txr-b6551fda77163f74983688409aaf0c13c8186bec.zip |
Changing read syntax for character literals, because we are going to
need the single quote in the Lisp way for suppressing evaluation,
eventually.
I'm going with a Scheme-compatible syntax for character literals.
It has a richer repertoire of standard character names than Common
Lisp, and has a x convention for coding characters in hex.
* lib.c (obj_print): Print characters in a Scheme-like way.
* parser.h (end_of_char): New function declared.
* parser.l (grammar): Implement rules for #\ syntax, with
involving new HASH_BACKSLASH token.
(end_of_regex): Enhancement: added check that end_of_regex is
called in correct state, like the one in end_of_char.
(end_of_char): New function.
* parser.y (repeat_rep_helper, o_elems_transform, define_transform,
lit_char_helper): Functions changed to static.
(rl): Function moved down, past the grammar section.
(HASH_BACKSLASH): New terminal symbol.
(chrlit): Grammar redesigned.
(char_from_name): New function.
* txr.1: Character syntax documented.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -920,7 +920,7 @@ directives are: @( a (b (c d) (e ) )) - @("apple" 'b' 3) + @("apple" #\eb #\espace 3) @(a /[a-z]*/ b) @@ -929,10 +929,17 @@ directives are: A symbol is lexically the same thing as a variable and the same rules apply. Tokens that look like numbers are treated as numbers. -String and character literals are delimited by double and single quotes, -respectively, and may not span multiple lines. Character literals must contain -exactly one character. Character and numeric escapes may be used within -literals to escape the quotes, and to denote control characters. +Character literals are introduced by the #\ 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. + +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. Quasiliterals are similar to string literals, except that they may contain variable references denoted by the usual @ syntax. The quasiliteral |