def to_ast(s):
    print s
    tp = parse(s)
    print tp
    astb = ASTBuilder()
    astb.sourcename = "test"
    return astb.dispatch(tp)
Beispiel #2
0
def to_ast(s):
    print s
    tp = parse(s)
    print tp
    astb = ASTBuilder()
    astb.sourcename = "test"
    return astb.dispatch(tp)
Beispiel #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)
Beispiel #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)
Beispiel #5
0
def to_ast(s):
    print s
    tp = parse(s)
    print tp
    return ASTBuilder().dispatch(tp)
Beispiel #6
0
def load_source(script_source):
    temp_tree = parse(script_source)
    return ASTBUILDER.dispatch(temp_tree)
Beispiel #7
0
def load_source(script_source, sourcename):
    temp_tree = parse(script_source)
    ASTBUILDER.sourcename = sourcename
    return ASTBUILDER.dispatch(temp_tree)
def load_source(script_source, sourcename):
    temp_tree = parse(script_source)
    ASTBUILDER.sourcename = sourcename
    return ASTBUILDER.dispatch(temp_tree)