0

I Know that there are several similar questions about ActionScript parsers, where I think the most appropriated answer is FlexPMD (http://sourceforge.net/adobe/flexpmd/home/Home/). Sadly, this answer does not completely work for me, because I need the parser written in ActionScript, which allows me to manipulate the source code (eg. wrap all functions of source code).

In order to achieve my goal, I also read about meta-programing for AS3, but it seems to be limited for my purpose.

4

2 回答 2

0

我还没有尝试过,但我遇到了这个,这看起来可能是您正在寻找的:

https://code.google.com/p/as3-commons/source/browse/trunk/as3-commons-asblocks/

于 2015-03-01T18:07:10.900 回答
0

我已经完成了vegascriptparser,它解析了一种近乎方言(VegaScript)。其他部分,vegascriptparser-bytecode 和 vegascriptparser-semantic,可能会在参考后完成。

还有自述文件上的有趣示例:

import vegascriptparser.*
import vegascriptparser.ast.*

const source = <![CDATA[
    trace(<{test ? 'x' : 'v'}/>)
    x?.v()
]]>.toString()

const program = Parser.quick(source).parse()

变成:

Program {
    directives: [
    ↪  ExpressionStatement { CallExpression {
            base: Identifier,
            args: [ ConditionalExpression, ],
        }}
    ↪  ExpressionStatement { OptionalExpression {
            base: Identifier,
            sub: CallExpression, 
        }]}
于 2019-06-04T13:11:22.557 回答