summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-10 07:08:07 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-10 07:08:07 -0700
commitcbf8c45bc7e737a849b62d4c2283aae11a3010e1 (patch)
tree80327ad951250d5966c4480b8fbb38baa8e5129e
parente046e1890f4655478a99fa7c1cb078eefdc54e00 (diff)
downloadtxr-cbf8c45bc7e737a849b62d4c2283aae11a3010e1.tar.gz
txr-cbf8c45bc7e737a849b62d4c2283aae11a3010e1.tar.bz2
txr-cbf8c45bc7e737a849b62d4c2283aae11a3010e1.zip
Don't scan C source code for Lisp symbols.
* eval.c (eval_init): Register package-alist, package-name and package-symbols intrinsics. * genvim.txr: Rather than scanning C sources for TXR Lisp symbols, iterate over the packages and their symbols, collecting anything which has a binding or is self-evaluating. To get the stdlib symbols, we trigger the autoloads by doing boundp queries on a few symbols. * txr.1: Document package-alist, package-name and package-symbols.
-rw-r--r--eval.c3
-rw-r--r--genvim.txr50
-rw-r--r--txr.138
3 files changed, 58 insertions, 33 deletions
diff --git a/eval.c b/eval.c
index dda00b49..ca4f1001 100644
--- a/eval.c
+++ b/eval.c
@@ -4441,6 +4441,9 @@ void eval_init(void)
reg_fun(intern(lit("make-package"), user_package), func_n1(make_package));
reg_fun(intern(lit("find-package"), user_package), func_n1(find_package));
reg_fun(intern(lit("delete-package"), user_package), func_n1(delete_package));
+ reg_fun(intern(lit("package-alist"), user_package), func_n0(package_alist));
+ reg_fun(intern(lit("package-name"), user_package), func_n1(package_name));
+ reg_fun(intern(lit("package-symbols"), user_package), func_n1(package_symbols));
reg_fun(intern(lit("intern"), user_package), func_n2o(intern, 1));
reg_fun(intern(lit("rehome-sym"), user_package), func_n2o(rehome_sym, 1));
reg_fun(intern(lit("symbolp"), user_package), func_n1(symbolp));
diff --git a/genvim.txr b/genvim.txr
index 9fbe15cd..40901d76 100644
--- a/genvim.txr
+++ b/genvim.txr
@@ -7,43 +7,27 @@ static void dir_tables_init(void)
@(until)
}
@(end)
-@(bind lib "share/txr/stdlib")
-@(next @(open-files ^(#*"eval.c rand.c signal.c stream.c gc.c glob.c"
- #*"syslog.c filter.c txr.c arith.c unwind.c cadr.c"
- ,*#`sysif.c struct.c @lib/place.tl @lib/ifa.tl`
- ,*#`@lib/ver.tl @lib/cadr.tl @lib/with-resources.tl`
- ,*#`@lib/txr-case.tl @lib/path-test.tl @lib/struct.tl`)))
-@(collect)
-@ (block)
-@ (cases)
-@/.*system_package.*/
-@ (accept)
-@ (or)
- reg_@/op|mac/(@{txl-sym-nostar}_star_s,@(skip)
-@ (bind txl-sym `@{txl-sym-nostar}*`)
-@ (or)
- reg_@/op|mac/(@{txl-sym}_s,@(skip)
-@ (or)
- reg_@/op|mac|fun/(@(skip)intern(lit("@{txl-sym}")@(skip)
-@ (or)
- reg_fun(@{txl-sym}_s,@(skip)
-@ (or)
- reg_var@/l?/(@{txl-sym-special}_s,@(skip)
-@ (bind txl-sym `*@{txl-sym-special}*`)
-@ (or)
- @/ *reg_varl?/(@(skip)intern(lit("@{txl-sym}")@(skip)
-@ (or)
-@/ *\((defun|defvarl?|defmacro)/ @{txl-sym} @(skip)
-@ (end)
-@ (set txl-sym @(regsub #/_/ #\- txl-sym))
-@ (end)
-@(end)
+@(do (each ((s '(*place-clobber-expander* *lib-version*
+ ifa txr-if with-resources path-exists-p
+ defstruct)))
+ (boundp s)))
+@(bind txl-sym
+ @(append-each* ((entry (package-alist))
+ (pkg-name [mapcar car entry])
+ (pkg [mapcar cdr entry]))
+ (append-each ((sym (package-symbols pkg)))
+ (when (or (boundp sym) (fboundp sym) (constantp sym))
+ (let ((qualif (casequal pkg-name
+ ("keyword" ":")
+ ("usr" "")
+ (t `@{pkg-name}:`))))
+ (list `@qualif@(symbol-name sym)`))))))
@(do (set [txr-sym 0..0] '("rep" "end" "and" "or"
"catch" "finally"
"until" "last"
"if" "else" "elif"
"include")))
-@(do (set [txl-sym 0..0] '("macro-time" "macrolet" "symacrolet")))
+@(do (set [txl-sym 0..0] '("macro-time")))
@(set (txr-sym txl-sym) (@(sort (uniq txr-sym)) @(sort (uniq txl-sym))))
@(bind bs "\\\\")
@(bind hex "0-9A-Fa-f")
@@ -76,7 +60,7 @@ static void dir_tables_init(void)
syn case match
syn spell toplevel
-setlocal iskeyword=a-z,A-Z,48-57,!,$,&,*,+,-,<,=,>,?,\\,_,~,/
+setlocal iskeyword=a-z,A-Z,48-57,!,$,&,*,+,-,:,<,=,>,?,\\,_,~,/
@ (rep) @{txl-sym}@(mod 0 4)@\nsyn keyword txl_keyword contained @{txl-sym}@(end)
@ (end)
@ (if txr-p)
diff --git a/txr.1 b/txr.1
index c8255ea2..0c8108fe 100644
--- a/txr.1
+++ b/txr.1
@@ -29880,6 +29880,44 @@ then it is returned. Otherwise
.code nil
is returned.
+.coNP Function @ package-alist
+.synb
+.mets (package-alist)
+.syne
+.desc
+The
+.code package-alist
+function returns an association list
+which contains an entry about each existing
+package.
+
+Each element of the list is a cons cell
+whose
+.code car
+field is the name of a package and whose
+.code cdr
+is a package object.
+
+.coNP Function @ package-name
+.synb
+.mets (package-name << package )
+.syne
+.desc
+The
+.code package-name
+function retrieves the name of a package.
+
+.coNP Function @ package-symbols
+.synb
+.mets (package-symbols << package )
+.syne
+.desc
+The
+.code package-symbols
+function returns a list of all the symbols
+which are interned in
+.metn package .
+
.coNP Function @ intern
.synb
.mets (intern < name <> [ package ])