diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | parser.l | 11 | ||||
-rw-r--r-- | txr.1 | 28 | ||||
-rw-r--r-- | txr.vim | 10 |
4 files changed, 47 insertions, 14 deletions
@@ -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 @@ -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(); @@ -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 @@ -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 |