1 Star 13 Fork 0

jianchiyiye/cylisp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sexp-aux.scm 2.57 KB
一键复制 编辑 原始数据 按行查看 历史
jianchiyiye 提交于 2022-06-28 10:54 . 0628release
;;(load "rew.scm")
(define-macro/err (rewrite-lisp-func/aux sexp cyl)
`(let* ((cur-cyl ,cyl)
(cur-unit (nth 0 cur-cyl))
(cur-typ (nth 3 cur-cyl))
)
;;(y-or-n "sexp->rewrite TEST:guide=~a,cur-unit=~a,cur-typ=~a,cyl-l=~a.\n" cyl-sexp-guide cur-unit cur-typ cyl-l)
(cond
((eq? cyl-sexp-guide 'lisp-quote)
(run/err rewrite-cyl/quote cur-cyl))
;;condition for if the first parameter:only cyl-l has 1 unit and is lisp-begin.
((eq? cyl-sexp-guide 'lisp-unquote)
(run/err rewrite-cyl/unquote cur-cyl))
((and (pair? cyl-l)(= (length cyl-l) 1)(eq? (nth 3 (nth 0 cyl-l)) 'lisp-begin))
(cond
;;rule:it must be ciyu after lisp-begin.
((and (string? cur-unit)(eq? cur-typ '词语))
(let* ((cur-coding-l (find-dict-coding-list cur-unit 'system))
(cur-coding (if cur-coding-l (nth 1 cur-coding-l) #f)) ;;(handle-new-lisp-func/aux)
(cur-lisp-type (if cur-coding-l (nth 0 cur-coding-l) #f))
)
(cond
((and cur-coding (eq? cur-lisp-type 'lisp系统函数))
(list cur-unit (string-length cur-unit) cur-coding cur-lisp-type (cyl-serial)))
(else
(err-msg "sexp->rewrite-lisp-func/aux:[~a]没有作为lisp 系统函数定义,请添加该函数定义。" cur-unit)
(set-car! (list-tail cur-cyl 3) 'lisp函数)
(set! cur-coding (append-new-coding cur-unit 'lisp函数 #f))
(set-car! (list-tail cur-cyl 2) cur-coding)
(if (not (search-dict-member cur-unit cyl-undefined-symbol-list))
(push (list cur-unit cur-coding '未定义函数 'lisp函数 cyl-current-define-function-name) cyl-undefined-symbol-list))
cur-cyl
)
)
))
(else
;;(exit-sexp (list 'err i (merge-num i ,cyl 1) '非法语法 (err-format 'sexp->rewrite-sexp-func/aux i "lisp调用的第一项[~a]不是lisp 系统函数。" cur-unit)))
cur-cyl
)))
(else
;;(y-or-n "rewrite-lisp-func/aux000:cur-cyl=~a\n" cur-cyl)
(let ((tmp-cyl (list cur-cyl)))
(set! tmp-cyl (rewrite-cyl/pure-yexp->syntax tmp-cyl))
(nth 0 tmp-cyl))
))))
(define (rewrite-cyl/quote cur-cyl)
;;(y-or-n "rewrite-cyl/quote:cur-cyl=~a\n" cur-cyl)
(let ((cur-unit (nth 0 cur-cyl))
(cur-typ (nth 3 cur-cyl))
)
(if (and (string? cur-unit)(eq? cur-typ '词语))
(begin
(set-car! (list-tail cur-cyl 3) '符号常量)
(set-car! (list-tail cur-cyl 2) 0)
cur-cyl
)
cur-cyl
)
))
(define (rewrite-cyl/unquote cur-cyl)
;;(y-or-n "rewrite-cyl/unquote:cur-cyl=~a\n" cur-cyl)
(let ((tmp-cyl (list cur-cyl)))
(set! tmp-cyl (rewrite-cyl/pure-yexp->syntax tmp-cyl))
(nth 0 tmp-cyl))
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Scheme
1
https://gitee.com/jianchiyiye/cylisp.git
git@gitee.com:jianchiyiye/cylisp.git
jianchiyiye
cylisp
cylisp
master

搜索帮助