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-- verbose

Examples

;; 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.eml

A 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/ccdynamic-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-environmentscheme-report-environment未实现。

For more info, run (help eval).

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java WebClient请求级别超时抛出名为default onErrorDropped的运算符   java JAXB外部绑定文件错误   Freemarker中的java转义宏参数值   java正在同步来自不同对象{已编辑}的线程   java如何在另一个类上更新活动中的元素   java Hibernate连接查询   java可以使用Apache Crunch创建类似于图形的数据结构吗?   java在JLabel的开头加上3个点   java 安卓应用程序显示线程错误   java@RequestBody在Spring中总是空的   java Android异步任务永远不会结束   具有多个属性的java Jaxws枚举   java中的安卓 Stripe InvalidRequestException   多线程java。util。非多线程程序中的ConcurrentModificationException   Minecraft Java插件如何删除HashMap中存储的所有块   空Java字符串的大小   从AJP连接器请求检索Shibboleth属性的java   oracle11g将Java类文件加载到Oracle数据库