python中的scheme解释器
lizpop的Python项目详细描述
lizpop是python中的scheme解释器。
安装
要求:
Lizpop requires Python 2.5 or later, but does not work in Python3.
要安装:
Simply run ^{tt1}$.
e.g.
$ tar zxvf lizpop-0.4.0.tar.gz $ cd lizpop-0.4.0 $ sudo python setup.py install
用法
以交互方式运行:
$ python -O -m lizpop.run
在文件中运行scheme脚本:
$ python -O -m lizpop.run yourfile.scm
有关命令行选项的详细信息:
$ python -O -m lizpop.run -h
功能
方案r5rs的子集
See the Restrictions section for more details.
具有与python的接口
e.g.
$ cat helloworld.py def hello(s="world"): return u"Hello %s!" % s.capitalize() $ python -O -m lizpop.run > (define *helloworld* (import "helloworld")) > (define hello (attr *helloworld* 'hello)) > (hello "friends") "Hello Friends!"For more details, See the IFPY.rst file in this package.
正则表达式文字。
The following literal is a Regular Expression Object.
#/PATTERN/FLAGS PATTERN: Regular expression pattern FLAGS: Regular expression flags. i-- ignore case m-- multi-line s-- dot matches all u-- Unicode dependent L-- locale dependent x-- verboseExamples
;; A simple matching > (re-search #/(\d+):(\d+)/ "Aug 14") ;; not match #f > (re-search #/(\d+):(\d+)/ "Aug 14 08:30") ;; match <_sre.SRE_Match object at ...> ;; Get subgroup > (re-group (re-search #/(\d+):(\d+)/ "Aug 14 08:30") 1 2) ("08" "30") ;; Replace string > (re-gsub #/<(\/?)h\d>/i "<\\1H3>" "<h1>Features:</h1>") "<H3>Features:</H3>" >For more info, run ^{tt2}$ procedure.
e.g. > (help-list #/(^re-)|(regex)/) > (help re-match re-search re-group re-gsub)
支持多字节字符
Only utf-8 encoding now.
eml(嵌入式lizpop)
EML is a template language for embedding Lizpop code in text file.
EML has the following simple specifications.
^{tt3}$ is a new string literal, but escape sequences in STRING (such as \n and \u3055) are not decoded.
Implicitly, ^{tt4}$ is added to the beginning of the input-port.
Implicitly, ^{tt5}$ is added to the end of the input-port.
Note: These ideas are inspired by BRL ( http://brl.sourceforge.net/ ).
To run EML, use ^{tt6}$ as command line option.
e.g. python -m lizpop.run -eml yourfile.emlA simple example
$ cat gcdlcm.eml <% (define numlist (map string->number *args*)) %> GCD of <% numlist %> is <%(apply gcd numlist)%>. LCM of <% numlist %> is <%(apply lcm numlist)%>. $ python -m lizpop.run -eml gcdlcm.eml -- 1533 37303 4307 GCD of (1533 37303 4307) is 73. LCM of (1533 37303 4307) is 6602631.For more examples:
please run ^{tt7}$ to see its help message.注:`lizpop + apache2 + mod_wsgi`
See the ^{tt9}$ file included in this package.
帮助功能
Lizpop has a help-function, it displays documentation for the given procedures or macros.
Usage:
(help var …)
(help-list regex-pattern)
e.g.
> (help invoke) Procedure: (invoke OBJ MESSAGE ARGS ... ) Invokes the OBJ's method named MESSAGE with ARGS ... .........................................................但是,目前,帮助文档只提供给 python接口相关函数。
有关详细信息,请运行(help)和(help help-list)。
- 注释:
我英语不好。所以帮助信息可能包括 英语中的错误或非自然表达。
限制
不支持卫生宏。
^{tt12}$ ^{tt13}$, and ^{tt14}$ are not implemented.
- Instead, traditional(non-hygienic) macros can be used.
- => run ^{tt15}$
字符串不可变。
Lizpop strings are implemented as Python unicode-string objects which are immutable. so, ^{tt16}$ and ^{tt17}$ don’t work.
call/cc和dynamic-wind仅部分实现。
Lizpop does not support full continuation.
Lizpop’s ^{tt20}$ is upward-only and non-reentrant. So, it can be used for non-local-exit, but cannot be used for co-routines or backtracking.
不支持复数和小数。
null-environment和scheme-report-environment未实现。
For more info, run (help eval).