[pypy-svn] r12777 - in pypy/branch/pycompiler: interpreter module/recparser module/recparser/compiler
ludal at codespeak.net
ludal at codespeak.net
Wed May 25 01:10:28 CEST 2005
Author: ludal
Date: Wed May 25 01:10:28 2005
New Revision: 12777
Modified:
pypy/branch/pycompiler/interpreter/compiler.py
pypy/branch/pycompiler/module/recparser/compiler/ast.py
pypy/branch/pycompiler/module/recparser/compiler/astgen.py
pypy/branch/pycompiler/module/recparser/compiler/symbols.py
pypy/branch/pycompiler/module/recparser/compiler/visitor.py
pypy/branch/pycompiler/module/recparser/pythonutil.py
pypy/branch/pycompiler/module/recparser/tuplebuilder.py
Log:
* changed recparser/compiler/symbols and visitor to use
a more 'standard' visitor pattern which should be closer to rpython
* misc fixes
* regenerate ast.py so that visit method accepts a variable number of arguments
Modified: pypy/branch/pycompiler/interpreter/compiler.py
==============================================================================
--- pypy/branch/pycompiler/interpreter/compiler.py (original)
+++ pypy/branch/pycompiler/interpreter/compiler.py Wed May 25 01:10:28 2005
@@ -201,8 +201,8 @@
flags |= __future__.generators.compiler_flag # always on (2.2 compat)
space = self.space
try:
- tree = # get the parse tree
- gen =
+ tree = None # get the parse tree
+ gen = None
# HACK use our parser instead of the CPython's one
compat.transformer.parser = compat
c = compat.pycompile(source, filename, mode, flags)
Modified: pypy/branch/pycompiler/module/recparser/compiler/ast.py
==============================================================================
--- pypy/branch/pycompiler/module/recparser/compiler/ast.py (original)
+++ pypy/branch/pycompiler/module/recparser/compiler/ast.py Wed May 25 01:10:28 2005
@@ -31,12 +31,12 @@
return self.getChildren()
def getChildNodes(self):
pass # implemented by subclasses
- def visit(self, visitor):
- return visitor.visitNode(self)
+ def visit(self, visitor, *args):
+ return visitor.visitNode(self, *args)
class EmptyNode(Node):
- def visit(self, visitor):
- return visitor.visitEmptyNode(self)
+ def visit(self, visitor, *args):
+ return visitor.visitEmptyNode(self, *args)
class Expression(Node):
# Expression is an artificial node class to support "eval"
@@ -53,8 +53,8 @@
def __repr__(self):
return "Expression(%s)" % (repr(self.node))
- def visit(self, visitor):
- return visitor.visitExpression(self)
+ def visit(self, visitor, *args):
+ return visitor.visitExpression(self, *args)
class Add(Node):
def __init__(self, (left, right), lineno=None):
@@ -71,8 +71,8 @@
def __repr__(self):
return "Add((%s, %s))" % (repr(self.left), repr(self.right))
- def visit(self, visitor):
- return visitor.visitAdd(self)
+ def visit(self, visitor, *args):
+ return visitor.visitAdd(self, *args)
class And(Node):
def __init__(self, nodes, lineno=None):
@@ -90,8 +90,8 @@
def __repr__(self):
return "And(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitAnd(self)
+ def visit(self, visitor, *args):
+ return visitor.visitAnd(self, *args)
class AssAttr(Node):
def __init__(self, expr, attrname, flags, lineno=None):
@@ -109,8 +109,8 @@
def __repr__(self):
return "AssAttr(%s, %s, %s)" % (repr(self.expr), repr(self.attrname), repr(self.flags))
- def visit(self, visitor):
- return visitor.visitAssAttr(self)
+ def visit(self, visitor, *args):
+ return visitor.visitAssAttr(self, *args)
class AssList(Node):
def __init__(self, nodes, lineno=None):
@@ -128,8 +128,8 @@
def __repr__(self):
return "AssList(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitAssList(self)
+ def visit(self, visitor, *args):
+ return visitor.visitAssList(self, *args)
class AssName(Node):
def __init__(self, name, flags, lineno=None):
@@ -146,8 +146,8 @@
def __repr__(self):
return "AssName(%s, %s)" % (repr(self.name), repr(self.flags))
- def visit(self, visitor):
- return visitor.visitAssName(self)
+ def visit(self, visitor, *args):
+ return visitor.visitAssName(self, *args)
class AssTuple(Node):
def __init__(self, nodes, lineno=None):
@@ -165,8 +165,8 @@
def __repr__(self):
return "AssTuple(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitAssTuple(self)
+ def visit(self, visitor, *args):
+ return visitor.visitAssTuple(self, *args)
class Assert(Node):
def __init__(self, test, fail, lineno=None):
@@ -190,8 +190,8 @@
def __repr__(self):
return "Assert(%s, %s)" % (repr(self.test), repr(self.fail))
- def visit(self, visitor):
- return visitor.visitAssert(self)
+ def visit(self, visitor, *args):
+ return visitor.visitAssert(self, *args)
class Assign(Node):
def __init__(self, nodes, expr, lineno=None):
@@ -214,8 +214,8 @@
def __repr__(self):
return "Assign(%s, %s)" % (repr(self.nodes), repr(self.expr))
- def visit(self, visitor):
- return visitor.visitAssign(self)
+ def visit(self, visitor, *args):
+ return visitor.visitAssign(self, *args)
class AugAssign(Node):
def __init__(self, node, op, expr, lineno=None):
@@ -233,8 +233,8 @@
def __repr__(self):
return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr))
- def visit(self, visitor):
- return visitor.visitAugAssign(self)
+ def visit(self, visitor, *args):
+ return visitor.visitAugAssign(self, *args)
class Backquote(Node):
def __init__(self, expr, lineno=None):
@@ -250,8 +250,8 @@
def __repr__(self):
return "Backquote(%s)" % (repr(self.expr),)
- def visit(self, visitor):
- return visitor.visitBackquote(self)
+ def visit(self, visitor, *args):
+ return visitor.visitBackquote(self, *args)
class Bitand(Node):
def __init__(self, nodes, lineno=None):
@@ -269,8 +269,8 @@
def __repr__(self):
return "Bitand(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitBitand(self)
+ def visit(self, visitor, *args):
+ return visitor.visitBitand(self, *args)
class Bitor(Node):
def __init__(self, nodes, lineno=None):
@@ -288,8 +288,8 @@
def __repr__(self):
return "Bitor(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitBitor(self)
+ def visit(self, visitor, *args):
+ return visitor.visitBitor(self, *args)
class Bitxor(Node):
def __init__(self, nodes, lineno=None):
@@ -307,8 +307,8 @@
def __repr__(self):
return "Bitxor(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitBitxor(self)
+ def visit(self, visitor, *args):
+ return visitor.visitBitxor(self, *args)
class Break(Node):
def __init__(self, lineno=None):
@@ -323,8 +323,8 @@
def __repr__(self):
return "Break()"
- def visit(self, visitor):
- return visitor.visitBreak(self)
+ def visit(self, visitor, *args):
+ return visitor.visitBreak(self, *args)
class CallFunc(Node):
def __init__(self, node, args, star_args = None, dstar_args = None, lineno=None):
@@ -355,8 +355,8 @@
def __repr__(self):
return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args))
- def visit(self, visitor):
- return visitor.visitCallFunc(self)
+ def visit(self, visitor, *args):
+ return visitor.visitCallFunc(self, *args)
class Class(Node):
def __init__(self, name, bases, doc, code, lineno=None):
@@ -383,8 +383,8 @@
def __repr__(self):
return "Class(%s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code))
- def visit(self, visitor):
- return visitor.visitClass(self)
+ def visit(self, visitor, *args):
+ return visitor.visitClass(self, *args)
class Compare(Node):
def __init__(self, expr, ops, lineno=None):
@@ -407,8 +407,8 @@
def __repr__(self):
return "Compare(%s, %s)" % (repr(self.expr), repr(self.ops))
- def visit(self, visitor):
- return visitor.visitCompare(self)
+ def visit(self, visitor, *args):
+ return visitor.visitCompare(self, *args)
class Const(Node):
def __init__(self, value, lineno=None):
@@ -424,8 +424,8 @@
def __repr__(self):
return "Const(%s)" % (repr(self.value),)
- def visit(self, visitor):
- return visitor.visitConst(self)
+ def visit(self, visitor, *args):
+ return visitor.visitConst(self, *args)
class Continue(Node):
def __init__(self, lineno=None):
@@ -440,8 +440,8 @@
def __repr__(self):
return "Continue()"
- def visit(self, visitor):
- return visitor.visitContinue(self)
+ def visit(self, visitor, *args):
+ return visitor.visitContinue(self, *args)
class Decorators(Node):
def __init__(self, nodes, lineno=None):
@@ -459,8 +459,8 @@
def __repr__(self):
return "Decorators(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitDecorators(self)
+ def visit(self, visitor, *args):
+ return visitor.visitDecorators(self, *args)
class Dict(Node):
def __init__(self, items, lineno=None):
@@ -478,8 +478,8 @@
def __repr__(self):
return "Dict(%s)" % (repr(self.items),)
- def visit(self, visitor):
- return visitor.visitDict(self)
+ def visit(self, visitor, *args):
+ return visitor.visitDict(self, *args)
class Discard(Node):
def __init__(self, expr, lineno=None):
@@ -495,8 +495,8 @@
def __repr__(self):
return "Discard(%s)" % (repr(self.expr),)
- def visit(self, visitor):
- return visitor.visitDiscard(self)
+ def visit(self, visitor, *args):
+ return visitor.visitDiscard(self, *args)
class Div(Node):
def __init__(self, (left, right), lineno=None):
@@ -513,8 +513,8 @@
def __repr__(self):
return "Div((%s, %s))" % (repr(self.left), repr(self.right))
- def visit(self, visitor):
- return visitor.visitDiv(self)
+ def visit(self, visitor, *args):
+ return visitor.visitDiv(self, *args)
class Ellipsis(Node):
def __init__(self, lineno=None):
@@ -529,8 +529,8 @@
def __repr__(self):
return "Ellipsis()"
- def visit(self, visitor):
- return visitor.visitEllipsis(self)
+ def visit(self, visitor, *args):
+ return visitor.visitEllipsis(self, *args)
class Exec(Node):
def __init__(self, expr, locals, globals, lineno=None):
@@ -558,8 +558,8 @@
def __repr__(self):
return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals))
- def visit(self, visitor):
- return visitor.visitExec(self)
+ def visit(self, visitor, *args):
+ return visitor.visitExec(self, *args)
class FloorDiv(Node):
def __init__(self, (left, right), lineno=None):
@@ -576,8 +576,8 @@
def __repr__(self):
return "FloorDiv((%s, %s))" % (repr(self.left), repr(self.right))
- def visit(self, visitor):
- return visitor.visitFloorDiv(self)
+ def visit(self, visitor, *args):
+ return visitor.visitFloorDiv(self, *args)
class For(Node):
def __init__(self, assign, list, body, else_, lineno=None):
@@ -607,8 +607,8 @@
def __repr__(self):
return "For(%s, %s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.body), repr(self.else_))
- def visit(self, visitor):
- return visitor.visitFor(self)
+ def visit(self, visitor, *args):
+ return visitor.visitFor(self, *args)
class From(Node):
def __init__(self, modname, names, lineno=None):
@@ -625,8 +625,8 @@
def __repr__(self):
return "From(%s, %s)" % (repr(self.modname), repr(self.names))
- def visit(self, visitor):
- return visitor.visitFrom(self)
+ def visit(self, visitor, *args):
+ return visitor.visitFrom(self, *args)
class Function(Node):
def __init__(self, decorators, name, argnames, defaults, flags, doc, code, lineno=None):
@@ -668,8 +668,8 @@
def __repr__(self):
return "Function(%s, %s, %s, %s, %s, %s, %s)" % (repr(self.decorators), repr(self.name), repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.doc), repr(self.code))
- def visit(self, visitor):
- return visitor.visitFunction(self)
+ def visit(self, visitor, *args):
+ return visitor.visitFunction(self, *args)
class GenExpr(Node):
def __init__(self, code, lineno=None):
@@ -689,8 +689,8 @@
def __repr__(self):
return "GenExpr(%s)" % (repr(self.code),)
- def visit(self, visitor):
- return visitor.visitGenExpr(self)
+ def visit(self, visitor, *args):
+ return visitor.visitGenExpr(self, *args)
class GenExprFor(Node):
def __init__(self, assign, iter, ifs, lineno=None):
@@ -718,8 +718,8 @@
def __repr__(self):
return "GenExprFor(%s, %s, %s)" % (repr(self.assign), repr(self.iter), repr(self.ifs))
- def visit(self, visitor):
- return visitor.visitGenExprFor(self)
+ def visit(self, visitor, *args):
+ return visitor.visitGenExprFor(self, *args)
class GenExprIf(Node):
def __init__(self, test, lineno=None):
@@ -735,8 +735,8 @@
def __repr__(self):
return "GenExprIf(%s)" % (repr(self.test),)
- def visit(self, visitor):
- return visitor.visitGenExprIf(self)
+ def visit(self, visitor, *args):
+ return visitor.visitGenExprIf(self, *args)
class GenExprInner(Node):
def __init__(self, expr, quals, lineno=None):
@@ -759,8 +759,8 @@
def __repr__(self):
return "GenExprInner(%s, %s)" % (repr(self.expr), repr(self.quals))
- def visit(self, visitor):
- return visitor.visitGenExprInner(self)
+ def visit(self, visitor, *args):
+ return visitor.visitGenExprInner(self, *args)
class Getattr(Node):
def __init__(self, expr, attrname, lineno=None):
@@ -777,8 +777,8 @@
def __repr__(self):
return "Getattr(%s, %s)" % (repr(self.expr), repr(self.attrname))
- def visit(self, visitor):
- return visitor.visitGetattr(self)
+ def visit(self, visitor, *args):
+ return visitor.visitGetattr(self, *args)
class Global(Node):
def __init__(self, names, lineno=None):
@@ -794,8 +794,8 @@
def __repr__(self):
return "Global(%s)" % (repr(self.names),)
- def visit(self, visitor):
- return visitor.visitGlobal(self)
+ def visit(self, visitor, *args):
+ return visitor.visitGlobal(self, *args)
class If(Node):
def __init__(self, tests, else_, lineno=None):
@@ -819,8 +819,8 @@
def __repr__(self):
return "If(%s, %s)" % (repr(self.tests), repr(self.else_))
- def visit(self, visitor):
- return visitor.visitIf(self)
+ def visit(self, visitor, *args):
+ return visitor.visitIf(self, *args)
class Import(Node):
def __init__(self, names, lineno=None):
@@ -836,8 +836,8 @@
def __repr__(self):
return "Import(%s)" % (repr(self.names),)
- def visit(self, visitor):
- return visitor.visitImport(self)
+ def visit(self, visitor, *args):
+ return visitor.visitImport(self, *args)
class Invert(Node):
def __init__(self, expr, lineno=None):
@@ -853,8 +853,8 @@
def __repr__(self):
return "Invert(%s)" % (repr(self.expr),)
- def visit(self, visitor):
- return visitor.visitInvert(self)
+ def visit(self, visitor, *args):
+ return visitor.visitInvert(self, *args)
class Keyword(Node):
def __init__(self, name, expr, lineno=None):
@@ -871,8 +871,8 @@
def __repr__(self):
return "Keyword(%s, %s)" % (repr(self.name), repr(self.expr))
- def visit(self, visitor):
- return visitor.visitKeyword(self)
+ def visit(self, visitor, *args):
+ return visitor.visitKeyword(self, *args)
class Lambda(Node):
def __init__(self, argnames, defaults, flags, code, lineno=None):
@@ -906,8 +906,8 @@
def __repr__(self):
return "Lambda(%s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.code))
- def visit(self, visitor):
- return visitor.visitLambda(self)
+ def visit(self, visitor, *args):
+ return visitor.visitLambda(self, *args)
class LeftShift(Node):
def __init__(self, (left, right), lineno=None):
@@ -924,8 +924,8 @@
def __repr__(self):
return "LeftShift((%s, %s))" % (repr(self.left), repr(self.right))
- def visit(self, visitor):
- return visitor.visitLeftShift(self)
+ def visit(self, visitor, *args):
+ return visitor.visitLeftShift(self, *args)
class List(Node):
def __init__(self, nodes, lineno=None):
@@ -943,8 +943,8 @@
def __repr__(self):
return "List(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitList(self)
+ def visit(self, visitor, *args):
+ return visitor.visitList(self, *args)
class ListComp(Node):
def __init__(self, expr, quals, lineno=None):
@@ -967,8 +967,8 @@
def __repr__(self):
return "ListComp(%s, %s)" % (repr(self.expr), repr(self.quals))
- def visit(self, visitor):
- return visitor.visitListComp(self)
+ def visit(self, visitor, *args):
+ return visitor.visitListComp(self, *args)
class ListCompFor(Node):
def __init__(self, assign, list, ifs, lineno=None):
@@ -994,8 +994,8 @@
def __repr__(self):
return "ListCompFor(%s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.ifs))
- def visit(self, visitor):
- return visitor.visitListCompFor(self)
+ def visit(self, visitor, *args):
+ return visitor.visitListCompFor(self, *args)
class ListCompIf(Node):
def __init__(self, test, lineno=None):
@@ -1011,8 +1011,8 @@
def __repr__(self):
return "ListCompIf(%s)" % (repr(self.test),)
- def visit(self, visitor):
- return visitor.visitListCompIf(self)
+ def visit(self, visitor, *args):
+ return visitor.visitListCompIf(self, *args)
class Mod(Node):
def __init__(self, (left, right), lineno=None):
@@ -1029,8 +1029,8 @@
def __repr__(self):
return "Mod((%s, %s))" % (repr(self.left), repr(self.right))
- def visit(self, visitor):
- return visitor.visitMod(self)
+ def visit(self, visitor, *args):
+ return visitor.visitMod(self, *args)
class Module(Node):
def __init__(self, doc, node, lineno=None):
@@ -1047,8 +1047,8 @@
def __repr__(self):
return "Module(%s, %s)" % (repr(self.doc), repr(self.node))
- def visit(self, visitor):
- return visitor.visitModule(self)
+ def visit(self, visitor, *args):
+ return visitor.visitModule(self, *args)
class Mul(Node):
def __init__(self, (left, right), lineno=None):
@@ -1065,8 +1065,8 @@
def __repr__(self):
return "Mul((%s, %s))" % (repr(self.left), repr(self.right))
- def visit(self, visitor):
- return visitor.visitMul(self)
+ def visit(self, visitor, *args):
+ return visitor.visitMul(self, *args)
class Name(Node):
def __init__(self, name, lineno=None):
@@ -1082,8 +1082,8 @@
def __repr__(self):
return "Name(%s)" % (repr(self.name),)
- def visit(self, visitor):
- return visitor.visitName(self)
+ def visit(self, visitor, *args):
+ return visitor.visitName(self, *args)
class Not(Node):
def __init__(self, expr, lineno=None):
@@ -1099,8 +1099,8 @@
def __repr__(self):
return "Not(%s)" % (repr(self.expr),)
- def visit(self, visitor):
- return visitor.visitNot(self)
+ def visit(self, visitor, *args):
+ return visitor.visitNot(self, *args)
class Or(Node):
def __init__(self, nodes, lineno=None):
@@ -1118,8 +1118,8 @@
def __repr__(self):
return "Or(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitOr(self)
+ def visit(self, visitor, *args):
+ return visitor.visitOr(self, *args)
class Pass(Node):
def __init__(self, lineno=None):
@@ -1134,8 +1134,8 @@
def __repr__(self):
return "Pass()"
- def visit(self, visitor):
- return visitor.visitPass(self)
+ def visit(self, visitor, *args):
+ return visitor.visitPass(self, *args)
class Power(Node):
def __init__(self, (left, right), lineno=None):
@@ -1152,8 +1152,8 @@
def __repr__(self):
return "Power((%s, %s))" % (repr(self.left), repr(self.right))
- def visit(self, visitor):
- return visitor.visitPower(self)
+ def visit(self, visitor, *args):
+ return visitor.visitPower(self, *args)
class Print(Node):
def __init__(self, nodes, dest, lineno=None):
@@ -1177,8 +1177,8 @@
def __repr__(self):
return "Print(%s, %s)" % (repr(self.nodes), repr(self.dest))
- def visit(self, visitor):
- return visitor.visitPrint(self)
+ def visit(self, visitor, *args):
+ return visitor.visitPrint(self, *args)
class Printnl(Node):
def __init__(self, nodes, dest, lineno=None):
@@ -1202,8 +1202,8 @@
def __repr__(self):
return "Printnl(%s, %s)" % (repr(self.nodes), repr(self.dest))
- def visit(self, visitor):
- return visitor.visitPrintnl(self)
+ def visit(self, visitor, *args):
+ return visitor.visitPrintnl(self, *args)
class Raise(Node):
def __init__(self, expr1, expr2, expr3, lineno=None):
@@ -1232,8 +1232,8 @@
def __repr__(self):
return "Raise(%s, %s, %s)" % (repr(self.expr1), repr(self.expr2), repr(self.expr3))
- def visit(self, visitor):
- return visitor.visitRaise(self)
+ def visit(self, visitor, *args):
+ return visitor.visitRaise(self, *args)
class Return(Node):
def __init__(self, value, lineno=None):
@@ -1249,8 +1249,8 @@
def __repr__(self):
return "Return(%s)" % (repr(self.value),)
- def visit(self, visitor):
- return visitor.visitReturn(self)
+ def visit(self, visitor, *args):
+ return visitor.visitReturn(self, *args)
class RightShift(Node):
def __init__(self, (left, right), lineno=None):
@@ -1267,8 +1267,8 @@
def __repr__(self):
return "RightShift((%s, %s))" % (repr(self.left), repr(self.right))
- def visit(self, visitor):
- return visitor.visitRightShift(self)
+ def visit(self, visitor, *args):
+ return visitor.visitRightShift(self, *args)
class Slice(Node):
def __init__(self, expr, flags, lower, upper, lineno=None):
@@ -1298,8 +1298,8 @@
def __repr__(self):
return "Slice(%s, %s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.lower), repr(self.upper))
- def visit(self, visitor):
- return visitor.visitSlice(self)
+ def visit(self, visitor, *args):
+ return visitor.visitSlice(self, *args)
class Sliceobj(Node):
def __init__(self, nodes, lineno=None):
@@ -1317,8 +1317,8 @@
def __repr__(self):
return "Sliceobj(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitSliceobj(self)
+ def visit(self, visitor, *args):
+ return visitor.visitSliceobj(self, *args)
class Stmt(Node):
def __init__(self, nodes, lineno=None):
@@ -1336,8 +1336,8 @@
def __repr__(self):
return "Stmt(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitStmt(self)
+ def visit(self, visitor, *args):
+ return visitor.visitStmt(self, *args)
class Sub(Node):
def __init__(self, (left, right), lineno=None):
@@ -1354,8 +1354,8 @@
def __repr__(self):
return "Sub((%s, %s))" % (repr(self.left), repr(self.right))
- def visit(self, visitor):
- return visitor.visitSub(self)
+ def visit(self, visitor, *args):
+ return visitor.visitSub(self, *args)
class Subscript(Node):
def __init__(self, expr, flags, subs, lineno=None):
@@ -1380,8 +1380,8 @@
def __repr__(self):
return "Subscript(%s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.subs))
- def visit(self, visitor):
- return visitor.visitSubscript(self)
+ def visit(self, visitor, *args):
+ return visitor.visitSubscript(self, *args)
class TryExcept(Node):
def __init__(self, body, handlers, else_, lineno=None):
@@ -1408,8 +1408,8 @@
def __repr__(self):
return "TryExcept(%s, %s, %s)" % (repr(self.body), repr(self.handlers), repr(self.else_))
- def visit(self, visitor):
- return visitor.visitTryExcept(self)
+ def visit(self, visitor, *args):
+ return visitor.visitTryExcept(self, *args)
class TryFinally(Node):
def __init__(self, body, final, lineno=None):
@@ -1426,8 +1426,8 @@
def __repr__(self):
return "TryFinally(%s, %s)" % (repr(self.body), repr(self.final))
- def visit(self, visitor):
- return visitor.visitTryFinally(self)
+ def visit(self, visitor, *args):
+ return visitor.visitTryFinally(self, *args)
class Tuple(Node):
def __init__(self, nodes, lineno=None):
@@ -1445,8 +1445,8 @@
def __repr__(self):
return "Tuple(%s)" % (repr(self.nodes),)
- def visit(self, visitor):
- return visitor.visitTuple(self)
+ def visit(self, visitor, *args):
+ return visitor.visitTuple(self, *args)
class UnaryAdd(Node):
def __init__(self, expr, lineno=None):
@@ -1462,8 +1462,8 @@
def __repr__(self):
return "UnaryAdd(%s)" % (repr(self.expr),)
- def visit(self, visitor):
- return visitor.visitUnaryAdd(self)
+ def visit(self, visitor, *args):
+ return visitor.visitUnaryAdd(self, *args)
class UnarySub(Node):
def __init__(self, expr, lineno=None):
@@ -1479,8 +1479,8 @@
def __repr__(self):
return "UnarySub(%s)" % (repr(self.expr),)
- def visit(self, visitor):
- return visitor.visitUnarySub(self)
+ def visit(self, visitor, *args):
+ return visitor.visitUnarySub(self, *args)
class While(Node):
def __init__(self, test, body, else_, lineno=None):
@@ -1507,8 +1507,8 @@
def __repr__(self):
return "While(%s, %s, %s)" % (repr(self.test), repr(self.body), repr(self.else_))
- def visit(self, visitor):
- return visitor.visitWhile(self)
+ def visit(self, visitor, *args):
+ return visitor.visitWhile(self, *args)
class Yield(Node):
def __init__(self, value, lineno=None):
@@ -1524,8 +1524,8 @@
def __repr__(self):
return "Yield(%s)" % (repr(self.value),)
- def visit(self, visitor):
- return visitor.visitYield(self)
+ def visit(self, visitor, *args):
+ return visitor.visitYield(self, *args)
for name, obj in globals().items():
if isinstance(obj, type) and issubclass(obj, Node):
Modified: pypy/branch/pycompiler/module/recparser/compiler/astgen.py
==============================================================================
--- pypy/branch/pycompiler/module/recparser/compiler/astgen.py (original)
+++ pypy/branch/pycompiler/module/recparser/compiler/astgen.py Wed May 25 01:10:28 2005
@@ -192,8 +192,8 @@
print >> buf, ' return "%s()"' % self.name
def _gen_visit(self, buf):
- print >> buf, " def visit(self, visitor):"
- print >> buf, " return visitor.visit%s(self)" % self.name
+ print >> buf, " def visit(self, visitor, *args):"
+ print >> buf, " return visitor.visit%s(self, *args)" % self.name
rx_init = re.compile('init\((.*)\):')
Modified: pypy/branch/pycompiler/module/recparser/compiler/symbols.py
==============================================================================
--- pypy/branch/pycompiler/module/recparser/compiler/symbols.py (original)
+++ pypy/branch/pycompiler/module/recparser/compiler/symbols.py Wed May 25 01:10:28 2005
@@ -216,7 +216,7 @@
# node that define new scopes
- def visitModule(self, node):
+ def visitModule(self, node ):
scope = self.module = self.scopes[node] = ModuleScope()
self.visit(node.node, scope)
Modified: pypy/branch/pycompiler/module/recparser/compiler/visitor.py
==============================================================================
--- pypy/branch/pycompiler/module/recparser/compiler/visitor.py (original)
+++ pypy/branch/pycompiler/module/recparser/compiler/visitor.py Wed May 25 01:10:28 2005
@@ -123,7 +123,7 @@
def default(self, node, *args):
for child in node.getChildNodes():
- self.dispatch(child, *args)
+ child.visit(self, *args)
def __getattr__(self, name ):
return self.default
Modified: pypy/branch/pycompiler/module/recparser/pythonutil.py
==============================================================================
--- pypy/branch/pycompiler/module/recparser/pythonutil.py (original)
+++ pypy/branch/pycompiler/module/recparser/pythonutil.py Wed May 25 01:10:28 2005
@@ -15,7 +15,6 @@
tp2 = parser.suite(pyf.read())
return tp2.totuple()
-
import symbol
def pypy_parse(filename):
"""parse <filename> using PyPy's parser module and return nested tuples
@@ -42,12 +41,16 @@
def ast_file_input( filename ):
pyf = file(filename,"r")
text = pyf.read()
+ return ast_srcfile_input( text, filename )
+
+def ast_srcfile_input( srctext, filename ):
+ # TODO do something with the filename
builder = TupleBuilder( PYTHON_PARSER.rules )
- pythonparse.parse_python_source( text, PYTHON_PARSER, "file_input", builder )
+ pythonparse.parse_python_source( srctext, PYTHON_PARSER, "file_input", builder )
tree = builder.stack[-1]
trans = Transformer()
ast = trans.transform( tree )
- return ast, tree
+ return ast
def ast_eval_input( textsrc ):
builder = TupleBuilder( PYTHON_PARSER.rules )
Modified: pypy/branch/pycompiler/module/recparser/tuplebuilder.py
==============================================================================
--- pypy/branch/pycompiler/module/recparser/tuplebuilder.py (original)
+++ pypy/branch/pycompiler/module/recparser/tuplebuilder.py Wed May 25 01:10:28 2005
@@ -21,7 +21,7 @@
class TupleBuilder(BaseGrammarBuilder):
"""A builder that directly produce the AST"""
- def __init__( self, rules=None, debug=0, lineno=False ):
+ def __init__( self, rules=None, debug=0, lineno=True ):
BaseGrammarBuilder.__init__(self, rules, debug )
self.lineno = lineno
More information about the Pypy-commit
mailing list