将cmake文件解析为抽象语法树。

cmakeast的Python项目详细描述


cmake ast
==


status
----

-----------[特拉维斯](https://img.shields.io/travis/polysquare/cmake ast.svg)](http://travis ci.org/polysquare/cmake ast)[![appveyor](https://img.shields.io/appveyor/ci/smspilaz/cmake ast.svg)(https://ci.appveyor.com/project/smspilaz/cmake ast)[![工作服](https://img.shields.io/covertalls/polysquare/cmake ast.svg)(http://covertalls.io/polysquare/cmake ast)[![pypiversion](https://img.shields.io/pypi/v/cmake ast.svg)(https://pypi.python.org/pypi/cmake ast)[![Pypipythons](https://img.shields.io/pypi/pyversions/cmake ast.svg)](https://pypi.python.org/pypi/cmake ast)[![许可证](https://img.shields.io/github/license/polysquare/cmake ast.svg)](http://github.com/polysquare/cmake ast)


`cmake ast'已针对每个随附最新版本cmake的cmake模块进行了测试。这些测试也在每个构建的持续集成环境中运行。它支持多行字符串和其他角点大小写。

您还可以通过使用"tokens"关键字参数进行标记化,向它传递一个
获得的标记列表。返回的是一个顶层节点,节点描述如下:


-(one)`type`
`type:variable string number compoundliteral variabledereference`
-(one)`string ``contents`

`body`

-(many)(`functioncall`,`ifstatement`,`foreachstatement`,`whilestatement`)

`functioncall`

-(一个)`word``name`
-(多个)`word``arguments`

`functiondefinition`

-(一个)`functioncall``header`
-(一个)`body``body`
-(一个)`functioncall``footer`

`macrodefinition`

-(一个)`ffunctioncall``header`
-(一)`body``body`
-(一)`functioncall``footer`

`ifstatement`

-(一)`functioncall``header`
-(一)`body``body`

`elseifstatement`

-(一)`functioncall``header`
-(一)`body``body`

`elsestatement`

-(一)`functioncall``header`
-(一)`body``body`

`ifblock`

-(一)`if statement``if`u statement`
-(多)`elseifstatement``else`ifs`
-(一个可选)`elsestatement``else`
-(一)`functioncall``footer`

`foreachstatement`

-(o)ne)`functioncall``foreach\u function`
-(一)`body``body`
-(一)`functioncall``footer`

`whilestatement`

-(一)`functioncall``while\u function`
-(一)`body``body`
-(一)`functioncall``footer`

每个节点还有一个'line`和'col'成员来表示在源文件中找到它的位置。


字类型别名存储在"ast"内的"word type"中。

默认情况下,它将遍历每个节点。与签名"def handler(name,node,depth)"匹配的侦听器可以作为以下关键字参数传递给"recurse(body,**kwargs)":

`|
``while ``while stmnt``whilestmnt``whilestmnt``whilestmnt``whilestatement`
``函数定义``函数定义`
``宏定义``宏定义`
``if块``if block`
``whilestatement``whilestmnt``whilestmnt``ifstatement`
``els ``foreachstatement`;
``foreach``foreach``foreach``foreach``foreach``foreach```欧洲投资基金会tmnt``elseifstatement`
如果要转储cmake文件的ast,还提供了"cmake print ast"工具。在
命令行


tokenization
----


要获得更低级别的表示,请使用'cmakeast.ast.tokenize(contents)`
,它只将文件分为标记。别名存储在"ast"中的"tokentype"
类中。标记对应如下:

`|`(`|
"rightparen `)`
"word `字母数字序列
"number `数字序列
"deref `字母数字序列de`${}`
`rst`文档注释
`comment`
`unquotedliteral`任何字符序列,包括标点符号|

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

推荐PyPI第三方库


热门话题
java将spring j_spring_安全检查迁移到登录   log4j2中自定义appender中AppConfig的java问题   在将java转换为Json时是否可以忽略内部类名和变量   用java将PDF文件转换为十六进制格式   java将值从AsyncTask返回到主类   java如何导入带有部署变量类名的静态函数?   java Spring Boot@ConfigurationProperties未从环境检索属性   java为什么API调用需要80毫秒的延迟才能到达控制器(在Google应用程序引擎中)?   XML配置中MarshallingMessageConverter中的java设置MarshallTo获取无效属性“MarshallTo”   java从群中获取facebook帖子   @ComponentScan的java excludeFilters不起作用   java将单选按钮值从一个类传递到另一个类   java使JTextArea在Swing中可滚动   java Android增强现实应用程序:将球坐标旋转到设备坐标系