用python 3编写的空白解释器
whitep的Python项目详细描述
whitepy
==
天然气管道代码::shell
$pip install whitepy
$whitepycli--help
用法:whitepycli[options]filename
whitespace解释器
options:
--debug/--no debug enable debug
--help显示此消息并退出。
$whitepycli sample_ws/hello world.ws
你好,世界!
来自github
'''''''''''
…代码::shell
$git clone https://github.com/yasn77/whitepy&;cd whitepy
$pip install-r requirements.txt
$。/whitepycli--help
用法:whitepycli[options]filename
whitespace解释器
选项:
--debug enable debug
--帮助显示此消息并退出。
$./whitepycli sample\u ws/hello world.ws
你好,世界!
什么是空白?
~~~~~~~~~~~~~~~~~~~~~~~~~
whitespace编程语言最初是由达勒姆大学的edwin brady
和chris morris[1]创建的,然后在2003年4月1日对
`slashdot<;https://slashdot.org>;``网站进行审查时得到了更广泛的曝光。作为一种有趣的开发方式,空白是一种试图使用
编程语言的尝试,这种语言使用的字符通常被
其他编程语言忽略,即``space`(ascii 32)、
``tab```(ascii 9)和``linefeed``(ascii 10)。副产品是
你可以在其他文本中实现空白代码(这使得编写一字多义计算机程序成为可能)。
如何编写空白?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>空白是一种基于命令堆栈的语言,有5个基本命令
称为*指令命令参数*(imp):
+————————————————————————————————————————————————————————————————imp+====================+======+
``[空格]`` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `+-——————+
——R/>教程[3]。原来的教程已经不可用了,但是可以使用"internet archive:wayback
machine<;http://archive.org/web/>;` ` ` ` ` ` ` ` ` ` ` ` ` `.
编写空白的最大困难之一是源代码在大多数编辑器中不立即可见。为了解决这个问题,许多
编辑器能够将空白字符表示为一些
其他字符。例如,在``vim``中可以使用
``````:set listchars=…`````和`````:set list```````````````````````````` vim`````````````````````````~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
r/>```lexerconstants.py`<;whitepy/lexerconstants.py>;``,它包含可以使用的有效imp及其有效参数还有其他定义,如整数表示。这些是从
`原始空白
tutorial<;https://web.archive.org/web/20030414001723/http://compsoc.dur.ac.uk:80/whitespace/tutorial.php>;``中获取的。
作为输入
(``lexer.lexer(line=lines)`),当调用方法
``lexer.get_all_tokens()``时,将从空白源文件创建一个标记和参数列表
。这些令牌存储在
lexer对象中,可以通过调用"lexer.tokens`"来检索。
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
驱动tokeniser的引擎是pythons``re``库,
特别是`re.scanner`。这是一个功能强大的库,可以轻松地
将文本拆分到所需的标记中。
``re.scanner``的文档并不多,可以在"python``re``
documentation<;https://docs.python.org/3.2/library/re.html writing-a-tokenizer>;``uuu,
的"6.2.5.9"部分找到,但是我找到了一些非常有用的文档和示例
`here<;http:///lucumr.pocooo.org/2015/11/18/pythons hidden re gems/>;` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `>
解析器` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^并据此执行。解析器的核心是方法映射的标记
(``parser.method\u map``),这是一个将标记映射到内部方法的``dict``结构。我相信这种方法可以帮助我用我自己的令牌实现来扩展解释器,并减少"parser.parse()"方法的大小。这是因为
减少了``parser.parse()``中所需的逻辑量,而
方法只需在``dict``中查找键即可。
+--—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————ww.amazon.co.uk/writing-com
Pilers Interpreters软件引擎的软件工程方法语言教程https://h0tsh0tt.wordpress.com/2016/
07/03/空白语言教程/
+---------------------------+---------------------------+
空白(维基百科)https://en.wikipedia.org/wiki/whites
(编程语言)
+---------------------------+---------------------------+
https://github.com/hostilefork/white
whites pace语言的解释器集合| spacers/
+---------------------------+---------------------------+
在线空白编译器,virtual https://github.com/vii5ard/whitespac
machine和ide e|
+————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————--——+———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————-————+
让我们构建一个编译器http://compiler s.iecc.com/crenshaw/
+———————————————————————————————————————————————————————————————————————————————————————————————————||
+---------------------------+---------------------------+
引用
~~~~~~~~~~~~
[1]
https://web.archive.org/web/20030412201917/http://compsoc.dur.ac.uk:80/whitespace/
[2]
https://developers.slashdot.org/story/03/04/01/0332202/new whitespace only编程语言
[3]
https://web.archive.org/web/20030414001723/http://compsoc.dur.ac.uk:80/whitespace/tutorial.php
。|构建状态图像::https://travis-ci.org/yasn77/whitepy.svg?branch=master
:目标:https://travis ci.org/yasn77/whitepy
==
天然气管道代码::shell
$pip install whitepy
$whitepycli--help
用法:whitepycli[options]filename
whitespace解释器
options:
--debug/--no debug enable debug
--help显示此消息并退出。
$whitepycli sample_ws/hello world.ws
你好,世界!
来自github
'''''''''''
…代码::shell
$git clone https://github.com/yasn77/whitepy&;cd whitepy
$pip install-r requirements.txt
$。/whitepycli--help
用法:whitepycli[options]filename
whitespace解释器
选项:
--debug enable debug
--帮助显示此消息并退出。
$./whitepycli sample\u ws/hello world.ws
你好,世界!
什么是空白?
~~~~~~~~~~~~~~~~~~~~~~~~~
whitespace编程语言最初是由达勒姆大学的edwin brady
和chris morris[1]创建的,然后在2003年4月1日对
`slashdot<;https://slashdot.org>;``网站进行审查时得到了更广泛的曝光。作为一种有趣的开发方式,空白是一种试图使用
编程语言的尝试,这种语言使用的字符通常被
其他编程语言忽略,即``space`(ascii 32)、
``tab```(ascii 9)和``linefeed``(ascii 10)。副产品是
你可以在其他文本中实现空白代码(这使得编写一字多义计算机程序成为可能)。
如何编写空白?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>空白是一种基于命令堆栈的语言,有5个基本命令
称为*指令命令参数*(imp):
+————————————————————————————————————————————————————————————————imp+====================+======+
``[空格]`` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `+-——————+
——R/>教程[3]。原来的教程已经不可用了,但是可以使用"internet archive:wayback
machine<;http://archive.org/web/>;` ` ` ` ` ` ` ` ` ` ` ` ` `.
编写空白的最大困难之一是源代码在大多数编辑器中不立即可见。为了解决这个问题,许多
编辑器能够将空白字符表示为一些
其他字符。例如,在``vim``中可以使用
``````:set listchars=…`````和`````:set list```````````````````````````` vim`````````````````````````~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
r/>```lexerconstants.py`<;whitepy/lexerconstants.py>;``,它包含可以使用的有效imp及其有效参数还有其他定义,如整数表示。这些是从
`原始空白
tutorial<;https://web.archive.org/web/20030414001723/http://compsoc.dur.ac.uk:80/whitespace/tutorial.php>;``中获取的。
作为输入
(``lexer.lexer(line=lines)`),当调用方法
``lexer.get_all_tokens()``时,将从空白源文件创建一个标记和参数列表
。这些令牌存储在
lexer对象中,可以通过调用"lexer.tokens`"来检索。
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
驱动tokeniser的引擎是pythons``re``库,
特别是`re.scanner`。这是一个功能强大的库,可以轻松地
将文本拆分到所需的标记中。
``re.scanner``的文档并不多,可以在"python``re``
documentation<;https://docs.python.org/3.2/library/re.html writing-a-tokenizer>;``uuu,
的"6.2.5.9"部分找到,但是我找到了一些非常有用的文档和示例
`here<;http:///lucumr.pocooo.org/2015/11/18/pythons hidden re gems/>;` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `>
解析器` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^并据此执行。解析器的核心是方法映射的标记
(``parser.method\u map``),这是一个将标记映射到内部方法的``dict``结构。我相信这种方法可以帮助我用我自己的令牌实现来扩展解释器,并减少"parser.parse()"方法的大小。这是因为
减少了``parser.parse()``中所需的逻辑量,而
方法只需在``dict``中查找键即可。
+--—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————ww.amazon.co.uk/writing-com
Pilers Interpreters软件引擎的软件工程方法语言教程https://h0tsh0tt.wordpress.com/2016/
07/03/空白语言教程/
+---------------------------+---------------------------+
空白(维基百科)https://en.wikipedia.org/wiki/whites
(编程语言)
+---------------------------+---------------------------+
https://github.com/hostilefork/white
whites pace语言的解释器集合| spacers/
+---------------------------+---------------------------+
在线空白编译器,virtual https://github.com/vii5ard/whitespac
machine和ide e|
+————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————--——+———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————-————+
让我们构建一个编译器http://compiler s.iecc.com/crenshaw/
+———————————————————————————————————————————————————————————————————————————————————————————————————||
+---------------------------+---------------------------+
引用
~~~~~~~~~~~~
[1]
https://web.archive.org/web/20030412201917/http://compsoc.dur.ac.uk:80/whitespace/
[2]
https://developers.slashdot.org/story/03/04/01/0332202/new whitespace only编程语言
[3]
https://web.archive.org/web/20030414001723/http://compsoc.dur.ac.uk:80/whitespace/tutorial.php
。|构建状态图像::https://travis-ci.org/yasn77/whitepy.svg?branch=master
:目标:https://travis ci.org/yasn77/whitepy