From 57bfb0fa5d8803fe9df5f1dac672b689e5f4e3d3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 28 Nov 2011 18:58:25 -0800 Subject: Adding streams functions to Lisp evaluator. * eval.c (op_let): Bugfix: was not evaluating var init forms. (reg_var): New static function. (eval_init): Registered numerous stream functions and the three standard streams. * lib.c (obj_print, obj_pprint): Modified to return a value. (init): eval_init called after stream_init, because eval needs the three standrad streams prepared. * lib.h (obj_print, obj_pprint): Declarations updated. * stream.c (format): Support t as a shorthand for standard output. (formatv, open_directory, open_file, open_pipe): New functions. (w_opendir): New static function. * stream.h (formatv, open_directory, open_file, open_pipe): Declared. * txr.vim: set iskeyword such that keyword can contain special characters. Set b:current_syntax to "lisp". (txl_keyword): New keyword category populated with TXR Lisp keywords defined as separate category. (txr_list): Contains txl_keyword. (txr_meta): Contains txl_keyword and txr_list. --- txr.vim | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'txr.vim') diff --git a/txr.vim b/txr.vim index 63875c5c..3ef872f4 100644 --- a/txr.vim +++ b/txr.vim @@ -8,7 +8,7 @@ " put this file there. " 2. In your .vimrc, add this command to associate *.txr files " with the txr filetype. -" :au BufRead,BufNewFile *.txr set filetype=txr +" :au BufRead,BufNewFile *.txr set filetype=txr | set lisp " " If you want syntax highlighting to be on automatically (for any language) " you need to add ":syntax on" in your .vimrc also. But you knew that already! @@ -16,6 +16,8 @@ syn case match syn spell toplevel +setlocal iskeyword=a-z,+,-,*,<,>,= + syn keyword txr_keyword contained skip trailer freeform block accept fail syn keyword txr_keyword contained next some all none and or syn keyword txr_keyword contained maybe cases choose gather collect coll until last end @@ -24,7 +26,37 @@ syn keyword txr_keyword contained repeat rep first last single empty syn keyword txr_keyword contained define try catch finally throw syn keyword txr_keyword contained defex throw deffilter filter eof eol -syn match txr_at "@[ \t]*@" +syn keyword txl_keyword contained let lambda call cond if and or defvar defun +syn keyword txl_keyword contained inc dec push pop gethash list append apply +syn keyword txl_keyword contained cons list atom null consp listp proper-listp +syn keyword txl_keyword contained length mapcar mappend apply +syn keyword txl_keyword contained + - * trunc mod numberp > < >= <= max min +syn keyword txl_keyword contained int-str + +syn keyword txl_keyword contained search-regex match-regex + +syn keyword txl_keyword contained make-hash gethash sethash pushhash remhash +syn keyword txl_keyword contained hash-count get-hash-userdata +syn keyword txl_keyword contained set-hash-userdata + +syn keyword txl_keyword contained eval + +syn keyword txl_keyword contained *stdout* *stdin* *stderr* +syn keyword txl_keyword contained format print pprint +syn keyword txl_keyword contained make-string-input-stream +syn keyword txl_keyword contained make-string-byte-input-stream +syn keyword txl_keyword contained make-string-output-stream +syn keyword txl_keyword contained get-string-from-stream +syn keyword txl_keyword contained make-strlist-output-stream +syn keyword txl_keyword contained get-list-from-stream +syn keyword txl_keyword contained close-stream +syn keyword txl_keyword contained get-line get-char get-byte +syn keyword txl_keyword contained put-string put-line put-char +syn keyword txl_keyword contained flush-stream open-directory +syn keyword txl_keyword contained open-file open-pipe + +set lispwords=let open-file + syn match txr_comment "@[ \t]*#.*" syn match txr_contin "@[ \t]*\\$" syn match txr_hashbang "^#!.*" @@ -42,9 +74,9 @@ syn region txr_bracevar matchgroup=Delimiter start="@[ \t]*[*]\?{" matchgroup=De 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 -syn region txr_list contained matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=txr_string,txr_regex,txr_num,txr_ident,txr_variable,txr_meta,txr_list,txr_quasilit,txr_chr +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 -syn region txr_meta contained matchgroup=Delimiter start="@[ \t]*(" matchgroup=Delimiter end=")" contains=txr_string,txr_regex,txr_num,txr_ident,txr_variable,txr_quasilit,txr_chr +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 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 @@ -56,6 +88,7 @@ hi def link txr_hashbang Comment hi def link txr_contin Comment hi def link txr_char String hi def link txr_keyword Keyword +hi def link txl_keyword Keyword hi def link txr_string String hi def link txr_chr String hi def link txr_quasilit String @@ -65,3 +98,5 @@ hi def link txr_variable Identifier hi def link txr_bracevar Identifier hi def link txr_ident Identifier hi def link txr_num Number + +let b:current_syntax = "lisp" -- cgit v1.2.3