我们的分析器与分析树输出看起来很相似。
前面已经提到的分析树,提供了一种表现Ruby源代码的格式。
ParseTree, as already mentioned, offers a format to represent Ruby source code.
这种表示比传统分析树不仅空间较小,而且进行结构匹配的速度快。
Compared with the conventional parse tree, this representation not only consumes less space, but also is faster for structure matching.
而分析树输出看起来还没有计划,很有可能把ANTLR产生的AST转化成分析树格式。
While ParseTree output doesn't seem to be planned, it's entirely possible to translate the ANTLR generated AST into the ParseTree format.
然而,分析树不是一个完整的解决方案,因为当前的版本没有给出树上各个节点的源码位置。
Yet, even ParseTree is not a complete solution, since it's current versions don't give the source locations of individual nodes.
其次,对输入句子进行预处理,包括句法分析树的建立,合法片段的抽取及片段组合形式的转换;
This process includes the establishment of the parse tree, the extraction of the legal fragments and the transformation of the fragment combination forms. Finally, according to the set …
RP的输出与语法分析树的输出相同:用ruby中的数组以及基本类型来表达的s-expression。
RP's output is the same as ParseTree's output: s-expressions using ruby's arrays and base types.
已有的基于分析树的工具,比如Ruby2Ruby可以把AST转换成Ruby源代码;如果某工具想修改AST并输出为Ruby源代码,这很有用。
Tools, based on ParseTree, already exist, such as Ruby2Ruby which can turn an AST back into Ruby source code; useful if a tool wants to modify an AST and then output it as Ruby source.
一个类似的方法已经被JParseTree (JRuby的一个分析树端口)所采用,现在JRuby一部分额外软件包(JRuby Extras)提供了常用Ruby类库的JRuby端口。
A similar approach is already used by JParseTree, a port of ParseTree that works on JRuby, now a part of JRuby Extras which provides JRuby ports of popular Ruby libraries.
因为可以使用类似语法分析树(ParseTree)的通用方法来对Ruby代码进行分析并获得抽象语法树(Abstract Syntax Tree),所以在Ruby历史上的一定时期内,纯ruby语法分析器的缺失被忽视了。
A lack of a pure Ruby parser has been negligible for some time in Ruby's history, since getting the Abstract Syntax Tree (AST) of some Ruby code was possible with utilities such as ParseTree.
因为可以使用类似语法分析树(ParseTree)的通用方法来对Ruby代码进行分析并获得抽象语法树(Abstract Syntax Tree),所以在Ruby历史上的一定时期内,纯ruby语法分析器的缺失被忽视了。
A lack of a pure Ruby parser has been negligible for some time in Ruby's history, since getting the Abstract Syntax Tree (AST) of some Ruby code was possible with utilities such as ParseTree.
应用推荐