diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-03-25 22:10:31 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-03-25 22:10:31 -0700 |
commit | f4a6c56c8e8841c1991c1bb44546681ccbdb8f3a (patch) | |
tree | 943413daf7f15ed66562552b9cb43c8ada7053d0 /txr.1 | |
parent | 4c6d387b73dca86caed48b1e786c5c1bc2c4716b (diff) | |
download | txr-f4a6c56c8e8841c1991c1bb44546681ccbdb8f3a.tar.gz txr-f4a6c56c8e8841c1991c1bb44546681ccbdb8f3a.tar.bz2 txr-f4a6c56c8e8841c1991c1bb44546681ccbdb8f3a.zip |
* eval.c (me_quasilist): New static function.
(eval_init): Register me_quasilist as quasilist macro expander.
* lib.c (quasilist_s): New global variable.
(obj_init): quasilist_s initialized.
* lib.h (quasilist_s): Declared.
* match.c (do_txreval): Handle quasilist syntax.
* parser.l (QWLIT): New exclusive state.
Extend lexical grammar to transition to QWLIT state upon
the #` or #*` sequence which kicks off a word literal,
and in that state, piecewise lexically analyze the QLL,
mostly by borrowing rules from quasiliterals.
* parser.y (QWORDS, QWSPLICE): New tokens.
(n_exprs): Integrate splicing form of QLL syntax.
(n_expr): Integrate non-splicing form of QLL syntax.
(litchars): Propagate line number info.
(quasilit): Fix "string literal" wording in error message.
* txr.1: Introduced WLL abbreviation for word list literals,
cleaned up the text a little, and documented QLL's.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 58 |
1 files changed, 48 insertions, 10 deletions
@@ -1131,16 +1131,16 @@ The first string literal is the string "foobar". The second two are "foo bar". .SS Word List Literals -A word list literal provides a convenient way to write a list of strings +A word list literal (WLL) provides a convenient way to write a list of strings when such a list can be given as whitespace-delimited words. -There are two flavors of the word list literal: the regular word list -literal which begins with #" (hash, double-quote) and the splicing -list literal which begins with #*" (hash, star, double-quote). +There are two flavors of the WLL: the regular WLL which begins with #" (hash, +double-quote) and the splicing list literal which begins with #*" (hash, star, +double-quote). -Both literals are terminated by a double quote, which may be escaped +Both types are terminated by a double quote, which may be escaped as \e" in order to include it as a character. All the escaping conventions -used in string literals can be used in words literals. +used in string literals can be used in word literals. Unlike in string literals, whitespace (tabs, spaces and newlines) is not significant in word literals: it separates words. Whitespace may be @@ -1156,9 +1156,9 @@ Example: #"abc\ def ghi" --> notates ("abc def" "ghi") -A splicing word literal differs from a word literal in that it deos not +A splicing word literal differs from a word literal in that it does not produce a list of string literals, but rather it produces a sequence of string -literal tokens that is merged into the surrounding syntax. +literals that is merged into the surrounding syntax. Example: @@ -1166,8 +1166,8 @@ Example: --> (1 2 3 "abc" "def" 4 5 ("abc" "def")) -The regular word list literal produced a single list object, but the splicing -word list literal expanded into multiple string literal objects. +The regular WLL produced a single list object, but the splicing +WLL expanded into multiple string literal objects. .SS String Quasiliterals @@ -1186,6 +1186,44 @@ the TXR pattern language when the quasiliteral occurs in the pattern language. Quasliterals can be split into multiple lines in the same way as ordinary string literals. +.SS Quasiword Lists Literals + +The quasiword list literals (QLL-s) are to quasiliterals what WLL-s are to +ordinary literals. (See the above section Word List Literals.) + +A QLL combines the convenience of the WLL +with the power of quasistrings. + +Just as in the case of WLL-s, there are two flavors of the +QLL: the regular QLL which begins with #` +(hash, backquote) and the splicing list literal which begins with #*` (hash, +star, backquote). + +Both types are terminated by a backquote, which may be escaped +as \e` in order to include it as a character. All the escaping conventions +used in quasiliterals can be used in QLL. + +Unlike in quasiliterals, whitespace (tabs, spaces and newlines) is not +significant in QLL: it separates words. Whitespace may be +escaped with a backslash in order to include it as a literal character. + +Note that the delimiting into words is done before the variable +substitution. If the variable a contains spaces, then #`@a` nevertheless +expands into a list of one item: the string derived from a. + +Example: + + #`abc @a ghi` --> notates (`abc` `@a` `ghi`) + + #`abc @d@e@f + ghi` --> notates (`abc` `@d@e@f` `ghi`) + + #`@a\ @b @c` --> notates (`@a @b` `@c`) + +A splicing QLL differs from an ordinary QLL in that it does not produce a list +of quasiliterals, but rather it produces a sequence of quasiliterals that is +merged into the surrounding syntax. + .SS Numbers TXR supports integers and floating-point numbers. |