diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-03-25 06:57:25 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-03-25 06:57:25 -0700 |
commit | c60f5a54deed7064cb8aa32fb91c684ad049d2d3 (patch) | |
tree | 7f49a16663477c67910e53aae3475e97613e2274 /txr.1 | |
parent | 8707c5ecbfc4ceeb1ceb2eb3015ce492bf99636a (diff) | |
download | txr-c60f5a54deed7064cb8aa32fb91c684ad049d2d3.tar.gz txr-c60f5a54deed7064cb8aa32fb91c684ad049d2d3.tar.bz2 txr-c60f5a54deed7064cb8aa32fb91c684ad049d2d3.zip |
Introducing word list literals.
* parser.l (WLIT): New exclusive start state.
Extend lexical grammar to transition to WLIT state upon
the #" or #*" sequence which kicks off a word literal,
and in that state, piecewise lexically analyze the literal,
mostly by borrowing rules from other literals.
* parser.y (WORDS, WSPLICE): New tokens.
(n_exprs): Integrate splicing form of word list literal syntax.
(n_expr): Integrate non-splicit for of word list literal syntax.
(litchars): Propagate line number info.
(wordslit): New grammar rule.
* txr.1: Updated.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -1129,6 +1129,46 @@ Example: 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 +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). + +Both literals 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. + +Unlike in string literals, whitespace (tabs, spaces and newlines) is not +significant in word literals: it separates words. Whitespace may be +escaped with a backslash in order to include it as a literal character. + + +Example: + + #"abc def ghi" --> notates ("abc" "def" "ghi") + + #"abc def + ghi" --> notates ("abc" "def" "ghi") + + #"abc\ def ghi" --> notates ("abc def" "ghi") + +A splicing word literal differs from a word literal in that it deos not +produce a list of string literals, but rather it produces a sequence of string +literal tokens that is merged into the surrounding syntax. + +Example: + + (1 2 3 #*"abc def" 4 5 #"abc def") + + --> (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. + .SS String Quasiliterals Quasiliterals are similar to string literals, except that they may |