def to_ast(s):
    print s
    tp = parse(s)
    print tp
    astb = ASTBuilder()
    astb.sourcename = "test"
    return astb.dispatch(tp)
Esempio n. 2
0
def to_ast(s):
    print s
    tp = parse(s)
    print tp
    astb = ASTBuilder()
    astb.sourcename = "test"
    return astb.dispatch(tp)
Esempio n. 3
0
 def Call(self, ctx, args=[], this=None):
     tam = len(args)
     if tam >= 1:
         fbody  = args[tam-1].GetValue().ToString(ctx)
         argslist = []
         for i in range(tam-1):
             argslist.append(args[i].GetValue().ToString(ctx))
         fargs = ','.join(argslist)
         functioncode = "function (%s) {%s}"%(fargs, fbody)
     else:
         functioncode = "function () {}"
     #remove program and sourcelements node
     funcnode = parse(functioncode).children[0].children[0]
     return ASTBUILDER.dispatch(funcnode).execute(ctx)
Esempio n. 4
0
 def Call(self, ctx, args=[], this=None):
     tam = len(args)
     if tam >= 1:
         fbody = args[tam - 1].GetValue().ToString(ctx)
         argslist = []
         for i in range(tam - 1):
             argslist.append(args[i].GetValue().ToString(ctx))
         fargs = ','.join(argslist)
         functioncode = "function (%s) {%s}" % (fargs, fbody)
     else:
         functioncode = "function () {}"
     #remove program and sourcelements node
     funcnode = parse(functioncode).children[0].children[0]
     return ASTBUILDER.dispatch(funcnode).execute(ctx)
Esempio n. 5
0
def to_ast(s):
    print s
    tp = parse(s)
    print tp
    return ASTBuilder().dispatch(tp)
Esempio n. 6
0
def load_source(script_source):
    temp_tree = parse(script_source)
    return ASTBUILDER.dispatch(temp_tree)
Esempio n. 7
0
def load_source(script_source, sourcename):
    temp_tree = parse(script_source)
    ASTBUILDER.sourcename = sourcename
    return ASTBUILDER.dispatch(temp_tree)
Esempio n. 8
0
def load_source(script_source, sourcename):
    temp_tree = parse(script_source)
    ASTBUILDER.sourcename = sourcename
    return ASTBUILDER.dispatch(temp_tree)