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