summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-12-14 19:52:24 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-12-14 19:52:24 -0800
commite3390f1ed75d58f78218acf22c2a9209a88a14a2 (patch)
tree684ddb7f1845ec0076fa5523704facdc8976a742
parent89baf71c475f494c139df7c7f29a593b5a0f7d61 (diff)
downloadtxr-e3390f1ed75d58f78218acf22c2a9209a88a14a2.tar.gz
txr-e3390f1ed75d58f78218acf22c2a9209a88a14a2.tar.bz2
txr-e3390f1ed75d58f78218acf22c2a9209a88a14a2.zip
@# comments are becoming obsolescent. @# comments
can now be used. Within nested forms, Lisp-compatible ; comments are suported. * parser.l: Support @# and ; comments. * txr.1: Documentation updated. * txr.vim: Updated.
-rw-r--r--ChangeLog12
-rw-r--r--parser.l11
-rw-r--r--txr.128
-rw-r--r--txr.vim10
4 files changed, 47 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 45abf33b..226f38f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2011-12-14 Kaz Kylheku <kaz@kylheku.com>
+ @# comments are becoming obsolescent. @# comments
+ can now be used. Within nested forms,
+ Lisp-compatible ; comments are suported.
+
+ * parser.l: Support @# and ; comments.
+
+ * txr.1: Documentation updated.
+
+ * txr.vim: Updated.
+
+2011-12-14 Kaz Kylheku <kaz@kylheku.com>
+
* lib.c (car, cdr): Set the lazy cons function to nil
after calling it.
(rplacd): Do not set the lazy cons function to nil
diff --git a/parser.l b/parser.l
index e7881a30..0ade291d 100644
--- a/parser.l
+++ b/parser.l
@@ -439,6 +439,9 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
return TEXT;
}
+<SPECIAL,NESTED>[;].* {
+ /* comment */
+ }
<SPECIAL,NESTED>{UANYN} {
yyerrprepf(lit("bad character in directive: '~a'"),
string_utf8(yytext), nao);
@@ -536,14 +539,14 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
yy_push_state(SPECIAL);
}
-<INITIAL>^@#.*\n {
+<INITIAL>^@[#;].*\n {
/* eat whole line comment */
lineno++;
}
-<INITIAL>@#.* {
- /* comment to end of line */
- }
+<INITIAL>@[#;].* {
+ /* comment to end of line */
+ }
<STRLIT>\" {
yy_pop_state();
diff --git a/txr.1 b/txr.1
index 37dca2a4..80dc14dd 100644
--- a/txr.1
+++ b/txr.1
@@ -170,9 +170,9 @@ Example:
a=1
b=2
-The @# comment syntax can be used for better formatting:
+The @; comment syntax can be used for better formatting:
- txr -c "@#
+ txr -c "@;
@a
@b"
@@ -258,15 +258,15 @@ or more @(output) directive directed to standard output.
.SS Comments
-A query may contain comments which are delimited by the sequence @# and
-extend to the end of the line. No whitespace can occur between the @ and #.
+A query may contain comments which are delimited by the sequence @; and
+extend to the end of the line. No whitespace can occur between the @ and ;.
A comment which begins on a line swallows that entire line, as well as the
newline which terminates it. In essence, the entire comment disappears.
If the comment follows some material in a line, then it does not consume
the newline. Thus, the following two queries are equivalent:
- 1. @a@# comment: match whole line against variable @a
- @# this comment disappears entirely
+ 1. @a@; comment: match whole line against variable @a
+ @; this comment disappears entirely
@b
2. @a
@@ -277,6 +277,10 @@ comment which follows does. Without this intuitive behavior,
line comment would give rise to empty lines that must match empty
lines in the data, leading to spurious mismatches.
+Instead of the ; character, the # character can be used. This is
+an obsolescent feature.
+
+
.SS Hash Bang Support
If the first line of a query begins with the characters #!,
@@ -1062,6 +1066,18 @@ There is no \e@ escape.
A number is made up of digits 0 through 9, optionally preceded by a + or -
sign.
+.SS Comments
+
+Comments of the form @; were already covered. Inside directives,
+comments are introduced just by a ; character.
+
+Example:
+
+ @(foo ; this is a comment
+ bar) ; this is another comment
+
+This is equivalent to @(foo bar).
+
.SS Directives-driven Syntax
Some directives not only denote an expression, but are also involved in
diff --git a/txr.vim b/txr.vim
index 26326137..974e136e 100644
--- a/txr.vim
+++ b/txr.vim
@@ -69,7 +69,7 @@ syn match txr_hash "#" contained
syn match txr_quote "[,']" contained
syn match txr_atat "@[ \t]*@"
-syn match txr_comment "@[ \t]*#.*"
+syn match txr_comment "@[ \t]*[#;].*"
syn match txr_contin "@[ \t]*\\$"
syn match txr_hashbang "^#!.*"
syn match txr_char "@[ \t]*\\."
@@ -78,17 +78,18 @@ syn match txr_char "@[ \t]*\\[0-9]\+"
syn match txr_variable "@[ \t]*[*]\?[A-Za-z_][A-Za-z0-9_]*"
syn match txr_chr "#\\x[A-Fa-f0-9]\+"
syn match txr_chr "#\\[a-zA-Z_][a-zA-Z0-9_]*"
+syn match txr_ncomment ";.*" contained
syn match txr_ident "[a-zA-Z0-9!$%&*+\-<=>?\\^_~]\+" contained
syn match txr_num "[+-]\?[0-9]\+" contained
syn region txr_bracevar matchgroup=Delimiter start="@[ \t]*[*]\?{" matchgroup=Delimiter end="}" contains=txr_num,txr_ident,xr_string,txr_list,txr_regex,txr_quasilit,txr_chr
-syn region txr_directive matchgroup=Delimiter start="@[ \t]*(" matchgroup=Delimiter end=")" contains=txr_keyword,txr_string,txr_list,txr_meta,txr_quasilit,txr_num,txr_ident,txr_regex,txr_string,txr_variable,txr_chr,txr_hash
+syn region txr_directive matchgroup=Delimiter start="@[ \t]*(" matchgroup=Delimiter end=")" contains=txr_keyword,txr_string,txr_list,txr_meta,txr_quasilit,txr_num,txr_ident,txr_regex,txr_string,txr_variable,txr_chr,txr_hash,txr_ncomment
-syn region txr_list contained matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=txl_keyword,txr_string,txr_regex,txr_num,txr_ident,txr_variable,txr_meta,txr_list,txr_quasilit,txr_chr,txr_hash,txr_quote
+syn region txr_list contained matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=txl_keyword,txr_string,txr_regex,txr_num,txr_ident,txr_variable,txr_meta,txr_list,txr_quasilit,txr_chr,txr_hash,txr_quote,txr_ncomment
-syn region txr_meta contained matchgroup=Delimiter start="@[ \t]*(" matchgroup=Delimiter end=")" contains=txl_keyword,txr_string,txr_list,txr_regex,txr_num,txr_ident,txr_variable,txr_quasilit,txr_chrb,txr_hash,txr_quote
+syn region txr_meta contained matchgroup=Delimiter start="@[ \t]*(" matchgroup=Delimiter end=")" contains=txl_keyword,txr_string,txr_list,txr_regex,txr_num,txr_ident,txr_variable,txr_quasilit,txr_chrb,txr_hash,txr_quote,txr_ncomment
syn region txr_string contained oneline start=+"+ skip=+\\\\\|\\"+ end=+"+
syn region txr_quasilit contained oneline start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=txr_directive,txr_variable,txr_bracevar
@@ -97,6 +98,7 @@ syn region txr_regdir oneline start=+@[ \t]*/+ skip=+\\\\\|\\/+ end=+/+
hi def link txr_atat String
hi def link txr_comment Comment
+hi def link txr_ncomment Comment
hi def link txr_hashbang Comment
hi def link txr_contin Comment
hi def link txr_char String