【文件属性】:
文件名称:bashlex:用于 bash 的 Python 解析器
文件大小:72KB
文件格式:ZIP
更新时间:2021-05-30 18:00:20
Python
bashlex - 用于 bash 的 Python 解析器
bashlex 是 GNU bash 内部使用的解析器的 Python 端口。
在大多数情况下,它是从 C 音译而来的,主要区别在于:
它不执行任何操作
它是可重入的
它生成一个完整的 AST
安装:
$ pip install bashlex
用法
$ python
>>> import bashlex
>>> parts = bashlex.parse('true && cat <(echo $(echo foo))')
>>> for ast in parts:
... print ast.dump()
ListNode(pos=(0, 31), parts=[
CommandNode(pos=(0, 4), parts=[
WordNode(pos=(0, 4), word='true')
【文件预览】:
bashlex-master
----MANIFEST.in(16B)
----bashlex()
--------tokenizer.py(41KB)
--------flags.py(3KB)
--------utils.py(2KB)
--------parser.py(26KB)
--------state.py(85B)
--------errors.py(280B)
--------__init__.py(114B)
--------yacc.py(126KB)
--------subst.py(13KB)
--------heredoc.py(2KB)
--------shutils.py(1KB)
--------ast.py(7KB)
----requirements.txt(7B)
----examples()
--------commandsubstitution-remover.py(2KB)
----.travis.yml(156B)
----LICENSE(34KB)
----setup.py(1KB)
----README.md(3KB)
----Makefile(162B)
----tests()
--------test-tokenizer.py(12KB)
--------test-parser.py(41KB)
----.gitignore(102B)