尝试扩展 Python 控制台添加中文关键字

2019-05-20 07:15:32 +08:00
 xuanwu

尝试扩展 Python 控制台添加中文关键字

1517 次点击
所在节点    分享创造
9 条回复
delectate
2019-05-20 08:33:04 +08:00
中文编程,就是闲的。
LokiSharp
2019-05-20 09:16:44 +08:00
pyparsing 性能太差了 antlr 还靠谱点
xuanwu
2019-05-20 10:35:28 +08:00
@LokiSharp 因为是参考了周蟒实现. 请问有性能比较出处吗?
LokiSharp
2019-05-20 11:49:30 +08:00
@xuanwu #3 https://qiita.com/osamunmun/items/54a00e963d1a7db0cf59

» python test.py
## benchmarker: release 4.0.1 (for python)
## python version: 3.5.1
## python compiler: GCC 4.2.1 (Apple Inc. build 5666) (dot 3)
## python platform: Darwin-15.6.0-x86_64-i386-64bit
## python executable: .../antlr/query/venv.d/bin/python
## cpu model: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
## parameters: loop=1000, cycle=1, extra=0

## real (total = user + sys)
antlr 34.1303 34.0900 34.0500 0.0400
pyparsing 159.7840 159.5700 158.7100 0.8600

## Ranking real
antlr 34.1303 (100.0) ********************
pyparsing 159.7840 ( 21.4) ****

## Matrix real [01] [02]
[01] antlr 34.1303 100.0 468.2
[02] pyparsing 159.7840 21.4 100.0
xuanwu
2019-05-20 11:52:21 +08:00
@LokiSharp 多谢. 回头试试 antlr 自带的 python 语法定义. 不过也许遥遥无期了..估计在那之前就会有像样的中文编程环境出现.
LokiSharp
2019-05-20 11:57:17 +08:00
@xuanwu #5 https://github.com/antlr/grammars-v4

antlr 对大部分语言的语法定义都有社区的实现,你可以用他们直接改个编译器。
xuanwu
2019-05-20 12:22:05 +08:00
@LokiSharp 嗯, 了解. 本来的打算是像周蟒那样包一层, 尽量轻量实现一个中文环境原型.
LokiSharp
2019-05-20 12:24:48 +08:00
@xuanwu #7 antlr 可以生成 C 代码,理论上可以直接挂在 CPython 上面做一次预编译,性能影响也不会太大
xuanwu
2019-05-20 14:02:46 +08:00
@LokiSharp :) 我说的轻量是工作量最小(关键我还不熟 C), 不过谢谢思路哈.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/565655

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX