summaryrefslogtreecommitdiffstats
path: root/Lib/compiler
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-10-18 21:57:37 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-10-18 21:57:37 (GMT)
commite0c446bb4ad67294f42d4cb53b4ff28413bd8dde (patch)
treeb4f286b4e6f2259ec47569561c4c62762e78b3f2 /Lib/compiler
parent8a57f00081b6f83168007fc701447d7926acc6c4 (diff)
downloadcpython-e0c446bb4ad67294f42d4cb53b4ff28413bd8dde.zip
cpython-e0c446bb4ad67294f42d4cb53b4ff28413bd8dde.tar.gz
cpython-e0c446bb4ad67294f42d4cb53b4ff28413bd8dde.tar.bz2
Whitespace normalization.
Diffstat (limited to 'Lib/compiler')
-rw-r--r--Lib/compiler/__init__.py3
-rw-r--r--Lib/compiler/ast.py2
-rw-r--r--Lib/compiler/future.py3
-rw-r--r--Lib/compiler/misc.py1
-rw-r--r--Lib/compiler/pyassem.py26
-rw-r--r--Lib/compiler/pycodegen.py38
-rw-r--r--Lib/compiler/symbols.py16
-rw-r--r--Lib/compiler/transformer.py18
-rw-r--r--Lib/compiler/visitor.py2
9 files changed, 53 insertions, 56 deletions
diff --git a/Lib/compiler/__init__.py b/Lib/compiler/__init__.py
index 1267b0c..13b05bf 100644
--- a/Lib/compiler/__init__.py
+++ b/Lib/compiler/__init__.py
@@ -15,7 +15,7 @@ walk(ast, visitor, verbose=None)
See compiler.visitor for details.
compile(source, filename, mode, flags=None, dont_inherit=None)
- Returns a code object. A replacement for the builtin compile() function.
+ Returns a code object. A replacement for the builtin compile() function.
compileFile(filename)
Generates a .pyc file by compiling filename.
@@ -24,4 +24,3 @@ compileFile(filename)
from transformer import parse, parseFile
from visitor import walk
from pycodegen import compile, compileFile
-
diff --git a/Lib/compiler/ast.py b/Lib/compiler/ast.py
index 9a5d53c..23c463b 100644
--- a/Lib/compiler/ast.py
+++ b/Lib/compiler/ast.py
@@ -438,7 +438,7 @@ class Function(Node):
self.varargs = 1
if flags & CO_VARKEYWORDS:
self.kwargs = 1
-
+
def getChildren(self):
diff --git a/Lib/compiler/future.py b/Lib/compiler/future.py
index 09ffe4a..868b7cbb 100644
--- a/Lib/compiler/future.py
+++ b/Lib/compiler/future.py
@@ -16,7 +16,7 @@ def is_future(stmt):
class FutureParser:
features = ("nested_scopes", "generators", "division")
-
+
def __init__(self):
self.found = {} # set
@@ -70,4 +70,3 @@ if __name__ == "__main__":
walk(tree, v)
print v.found
print
-
diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py
index b4bbe78..6d5eaa8 100644
--- a/Lib/compiler/misc.py
+++ b/Lib/compiler/misc.py
@@ -72,4 +72,3 @@ def set_filename(filename, tree):
node = worklist.pop(0)
node.filename = filename
worklist.extend(node.getChildNodes())
-
diff --git a/Lib/compiler/pyassem.py b/Lib/compiler/pyassem.py
index cc2d108..26b9001 100644
--- a/Lib/compiler/pyassem.py
+++ b/Lib/compiler/pyassem.py
@@ -55,7 +55,7 @@ class FlowGraph:
# these edges to get the blocks emitted in the right order,
# however. :-( If a client needs to remove these edges, call
# pruneEdges().
-
+
self.current.addNext(block)
self.startBlock(block)
@@ -110,13 +110,13 @@ class FlowGraph:
# XXX This is a total mess. There must be a better way to get
# the code blocks in the right order.
-
+
self.fixupOrderHonorNext(blocks, default_next)
self.fixupOrderForward(blocks, default_next)
def fixupOrderHonorNext(self, blocks, default_next):
"""Fix one problem with DFS.
-
+
The DFS uses child block, but doesn't know about the special
"next" block. As a result, the DFS can order blocks so that a
block isn't next to the right block for implicit control
@@ -200,14 +200,14 @@ class FlowGraph:
for c in chains:
for b in c:
blocks.append(b)
-
+
def getBlocks(self):
return self.blocks.elements()
def getRoot(self):
"""Return nodes appropriate for use with dominator"""
return self.entry
-
+
def getContainedGraphs(self):
l = []
for b in self.getBlocks():
@@ -246,7 +246,7 @@ class Block:
def __str__(self):
insts = map(str, self.insts)
return "<block %s %d:\n%s>" % (self.label, self.bid,
- string.join(insts, '\n'))
+ string.join(insts, '\n'))
def emit(self, inst):
op = inst[0]
@@ -331,7 +331,7 @@ class PyFlowGraph(FlowGraph):
self.argcount = getArgCount(args)
self.klass = klass
if optimized:
- self.flags = CO_OPTIMIZED | CO_NEWLOCALS
+ self.flags = CO_OPTIMIZED | CO_NEWLOCALS
else:
self.flags = 0
self.consts = []
@@ -567,7 +567,7 @@ class PyFlowGraph(FlowGraph):
for name, obj in locals().items():
if name[:9] == "_convert_":
opname = name[9:]
- _converters[opname] = obj
+ _converters[opname] = obj
del name, obj, opname
def makeByteCode(self):
@@ -623,7 +623,7 @@ class PyFlowGraph(FlowGraph):
elt = elt.getCode()
l.append(elt)
return tuple(l)
-
+
def isJump(opname):
if opname[:4] == 'JUMP':
return 1
@@ -654,7 +654,7 @@ def twobyte(val):
class LineAddrTable:
"""lnotab
-
+
This class builds the lnotab, which is documented in compile.c.
Here's a brief recap:
@@ -717,7 +717,7 @@ class LineAddrTable:
def getTable(self):
return string.join(map(chr, self.lnotab), '')
-
+
class StackDepthTracker:
# XXX 1. need to keep track of stack depth on jumps
# XXX 2. at least partly as a result, this code is broken
@@ -792,7 +792,7 @@ class StackDepthTracker:
('BINARY_', -1),
('LOAD_', 1),
]
-
+
def UNPACK_SEQUENCE(self, count):
return count-1
def BUILD_TUPLE(self, count):
@@ -820,5 +820,5 @@ class StackDepthTracker:
return -2
def DUP_TOPX(self, argc):
return argc
-
+
findDepth = StackDepthTracker().findDepth
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
index 3cdf108..88767a4 100644
--- a/Lib/compiler/pycodegen.py
+++ b/Lib/compiler/pycodegen.py
@@ -36,7 +36,7 @@ END_FINALLY = 4
class BlockStack(misc.Stack):
__super_init = misc.Stack.__init__
-
+
def __init__(self):
self.__super_init(self)
self.loop = None
@@ -59,7 +59,7 @@ def compile(source, filename, mode, flags=None, dont_inherit=None):
"""Replacement for builtin compile() function"""
if flags is not None or dont_inherit is not None:
raise RuntimeError, "not implemented yet"
-
+
if mode == "single":
gen = Interactive(source, filename)
elif mode == "exec":
@@ -198,7 +198,7 @@ class CodeGenerator:
NameFinder, FunctionGen, and ClassGen. These attributes can be
defined in the initClass() method, which is a hook for
initializing these methods after all the classes have been
- defined.
+ defined.
"""
optimized = 0 # is namespace access optimized?
@@ -312,7 +312,7 @@ class CodeGenerator:
self.emit(prefix + '_NAME', name)
def set_lineno(self, node, force=0):
- """Emit SET_LINENO if node has lineno attribute and it is
+ """Emit SET_LINENO if node has lineno attribute and it is
different than the last lineno emitted.
Returns true if SET_LINENO was emitted.
@@ -513,7 +513,7 @@ class CodeGenerator:
self.emit('CONTINUE_LOOP', loop_block)
self.nextBlock()
elif kind == END_FINALLY:
- msg = "'continue' not allowed inside 'finally' clause (%s, %d)"
+ msg = "'continue' not allowed inside 'finally' clause (%s, %d)"
raise SyntaxError, msg % (node.filename, node.lineno)
def visitTest(self, node, jump):
@@ -558,7 +558,7 @@ class CodeGenerator:
# list comprehensions
__list_count = 0
-
+
def visitListComp(self, node):
self.set_lineno(node)
# setup list
@@ -568,7 +568,7 @@ class CodeGenerator:
self.emit('DUP_TOP')
self.emit('LOAD_ATTR', 'append')
self._implicitNameOp('STORE', append)
-
+
stack = []
for i, for_ in zip(range(len(node.quals)), node.quals):
start, anchor = self.visit(for_)
@@ -583,7 +583,7 @@ class CodeGenerator:
self.visit(node.expr)
self.emit('CALL_FUNCTION', 1)
self.emit('POP_TOP')
-
+
for start, cont, anchor in stack:
if cont:
skip_one = self.newBlock()
@@ -594,7 +594,7 @@ class CodeGenerator:
self.emit('JUMP_ABSOLUTE', start)
self.startBlock(anchor)
self._implicitNameOp('DELETE', append)
-
+
self.__list_count = self.__list_count - 1
def visitListCompFor(self, node):
@@ -675,7 +675,7 @@ class CodeGenerator:
self.setups.pop()
self.emit('JUMP_FORWARD', lElse)
self.startBlock(handlers)
-
+
last = len(node.handlers) - 1
for i in range(len(node.handlers)):
expr, target, body = node.handlers[i]
@@ -707,7 +707,7 @@ class CodeGenerator:
self.nextBlock(lElse)
self.visit(node.else_)
self.nextBlock(end)
-
+
def visitTryFinally(self, node):
body = self.newBlock()
final = self.newBlock()
@@ -746,7 +746,7 @@ class CodeGenerator:
def visitName(self, node):
self.set_lineno(node)
self.loadName(node.name)
-
+
def visitPass(self, node):
self.set_lineno(node)
@@ -1139,7 +1139,7 @@ class ModuleCodeGenerator(NestedScopeMixin, CodeGenerator):
__super_init = CodeGenerator.__init__
scopes = None
-
+
def __init__(self, tree):
self.graph = pyassem.PyFlowGraph("<module>", tree.filename)
self.futures = future.find_futures(tree)
@@ -1154,7 +1154,7 @@ class ExpressionCodeGenerator(NestedScopeMixin, CodeGenerator):
scopes = None
futures = ()
-
+
def __init__(self, tree):
self.graph = pyassem.PyFlowGraph("<expression>", tree.filename)
self.__super_init()
@@ -1171,7 +1171,7 @@ class InteractiveCodeGenerator(NestedScopeMixin, CodeGenerator):
scopes = None
futures = ()
-
+
def __init__(self, tree):
self.graph = pyassem.PyFlowGraph("<interactive>", tree.filename)
self.__super_init()
@@ -1201,8 +1201,8 @@ class AbstractFunctionCode:
else:
name = func.name
args, hasTupleArg = generateArgList(func.argnames)
- self.graph = pyassem.PyFlowGraph(name, func.filename, args,
- optimized=1)
+ self.graph = pyassem.PyFlowGraph(name, func.filename, args,
+ optimized=1)
self.isLambda = isLambda
self.super_init()
@@ -1234,7 +1234,7 @@ class AbstractFunctionCode:
if type(arg) == types.TupleType:
self.emit('LOAD_FAST', '.%d' % (i * 2))
self.unpackSequence(arg)
-
+
def unpackSequence(self, tup):
if VERSION > 1:
self.emit('UNPACK_SEQUENCE', len(tup))
@@ -1249,7 +1249,7 @@ class AbstractFunctionCode:
unpackTuple = unpackSequence
class FunctionCodeGenerator(NestedScopeMixin, AbstractFunctionCode,
- CodeGenerator):
+ CodeGenerator):
super_init = CodeGenerator.__init__ # call be other init
scopes = None
diff --git a/Lib/compiler/symbols.py b/Lib/compiler/symbols.py
index bf9a724..200341f 100644
--- a/Lib/compiler/symbols.py
+++ b/Lib/compiler/symbols.py
@@ -131,7 +131,7 @@ class Scope:
rather than free.
Be careful to stop if a child does not think the name is
- free.
+ free.
"""
self.globals[name] = 1
if self.frees.has_key(name):
@@ -172,7 +172,7 @@ class Scope:
class ModuleScope(Scope):
__super_init = Scope.__init__
-
+
def __init__(self):
self.__super_init("global", self)
@@ -183,7 +183,7 @@ class LambdaScope(FunctionScope):
__super_init = Scope.__init__
__counter = 1
-
+
def __init__(self, module, klass=None):
i = self.__counter
self.__counter += 1
@@ -199,7 +199,7 @@ class SymbolVisitor:
def __init__(self):
self.scopes = {}
self.klass = None
-
+
# node that define new scopes
def visitModule(self, node):
@@ -217,7 +217,7 @@ class SymbolVisitor:
self._do_args(scope, node.argnames)
self.visit(node.code, scope)
self.handle_free_vars(scope, parent)
-
+
def visitLambda(self, node, parent):
for n in node.defaults:
self.visit(n, parent)
@@ -326,7 +326,7 @@ class SymbolVisitor:
self.visit(node.lower, scope, 0)
if node.upper:
self.visit(node.upper, scope, 0)
-
+
def visitAugAssign(self, node, scope):
# If the LHS is a name, then this counts as assignment.
# Otherwise, it's just use.
@@ -371,8 +371,8 @@ if __name__ == "__main__":
def get_names(syms):
return [s for s in [s.get_name() for s in syms.get_symbols()]
- if not (s.startswith('_[') or s.startswith('.'))]
-
+ if not (s.startswith('_[') or s.startswith('.'))]
+
for file in sys.argv[1:]:
print file
f = open(file)
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index 88b3dac..9875561 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -692,14 +692,14 @@ class Transformer:
n = Backquote(self.com_node(nodelist[1]))
n.lineno = nodelist[0][2]
return n
-
+
def atom_number(self, nodelist):
### need to verify this matches compile.c
k = eval(nodelist[0][1])
n = Const(k)
n.lineno = nodelist[0][2]
return n
-
+
def atom_string(self, nodelist):
### need to verify this matches compile.c
k = ''
@@ -743,7 +743,7 @@ class Transformer:
# here, Render it harmless. (genc discards ('discard',
# ('const', xxxx)) Nodes)
return Discard(Const(None))
-
+
def com_arglist(self, nodelist):
# varargslist:
# (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME]
@@ -805,7 +805,7 @@ class Transformer:
return node[1][1]
def com_fplist(self, node):
- # fplist: fpdef (',' fpdef)* [',']
+ # fplist: fpdef (',' fpdef)* [',']
if len(node) == 2:
return self.com_fpdef(node[1])
list = []
@@ -854,7 +854,7 @@ class Transformer:
def com_try_finally(self, nodelist):
# try_fin_stmt: "try" ":" suite "finally" ":" suite
n = TryFinally(self.com_node(nodelist[2]),
- self.com_node(nodelist[5]))
+ self.com_node(nodelist[5]))
n.lineno = nodelist[0][2]
return n
@@ -922,7 +922,7 @@ class Transformer:
raise SyntaxError, "can't assign to operator"
primary = self.com_apply_trailer(primary, ch)
return self.com_assign_trailer(primary, node[-1],
- assigning)
+ assigning)
node = node[1]
elif t == symbol.atom:
t = node[1][0]
@@ -1023,7 +1023,7 @@ class Transformer:
# list_if: 'if' test [list_iter]
# XXX should raise SyntaxError for assignment
-
+
lineno = node[1][2]
fors = []
while node:
@@ -1100,7 +1100,7 @@ class Transformer:
for i in range(1, len_nodelist, 2):
node = nodelist[i]
if node[0] == token.STAR or node[0] == token.DOUBLESTAR:
- break
+ break
kw, result = self.com_argument(node, kw)
args.append(result)
else:
@@ -1145,7 +1145,7 @@ class Transformer:
def com_subscriptlist(self, primary, nodelist, assigning):
# slicing: simple_slicing | extended_slicing
# simple_slicing: primary "[" short_slice "]"
- # extended_slicing: primary "[" slice_list "]"
+ # extended_slicing: primary "[" slice_list "]"
# slice_list: slice_item ("," slice_item)* [","]
# backwards compat slice for '[i:j]'
diff --git a/Lib/compiler/visitor.py b/Lib/compiler/visitor.py
index 0560619..d7ae864 100644
--- a/Lib/compiler/visitor.py
+++ b/Lib/compiler/visitor.py
@@ -78,7 +78,7 @@ class ExampleASTVisitor(ASTVisitor):
you still have to do.
"""
examples = {}
-
+
def dispatch(self, node, *args):
self.node = node
meth = self._cache.get(node.__class__, None)