/usr/lib64/python2.7/compiler
NameSizeModeActions
ast.py375080644editdlrm
ast.pyc721250644editdlrm
ast.pyo721250644editdlrm
consts.py4680644editdlrm
consts.pyc7370644editdlrm
consts.pyo7370644editdlrm
future.py18930644editdlrm
future.pyc29560644editdlrm
future.pyo29560644editdlrm
misc.py17940644editdlrm
misc.pyc37330644editdlrm
misc.pyo37330644editdlrm
pyassem.py242680644editdlrm
pyassem.pyc259510644editdlrm
pyassem.pyo253770644editdlrm
pycodegen.py478090644editdlrm
pycodegen.pyc565150644editdlrm
pycodegen.pyo560710644editdlrm
symbols.py144890644editdlrm
symbols.pyc176770644editdlrm
symbols.pyo176430644editdlrm
syntax.py14440644editdlrm
syntax.pyc18820644editdlrm
syntax.pyo18820644editdlrm
transformer.py531160644editdlrm
transformer.pyc476450644editdlrm
transformer.pyo458300644editdlrm
visitor.py38960644editdlrm
visitor.pyc41870644editdlrm
visitor.pyo41870644editdlrm
__init__.py10230644editdlrm
__init__.pyc12970644editdlrm
__init__.pyo12970644editdlrm
Edit: /usr/lib64/python2.7/compiler/syntax.py (1444B)
"""Check for errs in the AST. The Python parser does not catch all syntax errors. Others, like assignments with invalid targets, are caught in the code generation phase. The compiler package catches some errors in the transformer module. But it seems clearer to write checkers that use the AST to detect errors. """ from compiler import ast, walk def check(tree, multi=None): v = SyntaxErrorChecker(multi) walk(tree, v) return v.errors class SyntaxErrorChecker: """A visitor to find syntax errors in the AST.""" def __init__(self, multi=None): """Create new visitor object. If optional argument multi is not None, then print messages for each error rather than raising a SyntaxError for the first. """ self.multi = multi self.errors = 0 def error(self, node, msg): self.errors = self.errors + 1 if self.multi is not None: print "%s:%s: %s" % (node.filename, node.lineno, msg) else: raise SyntaxError, "%s (%s:%s)" % (msg, node.filename, node.lineno) def visitAssign(self, node): # the transformer module handles many of these pass ## for target in node.nodes: ## if isinstance(target, ast.AssList): ## if target.lineno is None: ## target.lineno = node.lineno ## self.error(target, "can't assign to list comprehension")