404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.145.108.87: ~ $
#-----------------------------------------------------------------
# plyparser.py
#
# PLYParser class and other utilites for simplifying programming
# parsers with PLY
#
# Copyright (C) 2008-2015, Eli Bendersky
# License: BSD
#-----------------------------------------------------------------


class Coord(object):
    """ Coordinates of a syntactic element. Consists of:
            - File name
            - Line number
            - (optional) column number, for the Lexer
    """
    __slots__ = ('file', 'line', 'column', '__weakref__')
    def __init__(self, file, line, column=None):
        self.file = file
        self.line = line
        self.column = column

    def __str__(self):
        str = "%s:%s" % (self.file, self.line)
        if self.column: str += ":%s" % self.column
        return str


class ParseError(Exception): pass


class PLYParser(object):
    def _create_opt_rule(self, rulename):
        """ Given a rule name, creates an optional ply.yacc rule
            for it. The name of the optional rule is
            <rulename>_opt
        """
        optname = rulename + '_opt'

        def optrule(self, p):
            p[0] = p[1]

        optrule.__doc__ = '%s : empty\n| %s' % (optname, rulename)
        optrule.__name__ = 'p_%s' % optname
        setattr(self.__class__, optrule.__name__, optrule)

    def _coord(self, lineno, column=None):
        return Coord(
                file=self.clex.filename,
                line=lineno,
                column=column)

    def _parse_error(self, msg, coord):
        raise ParseError("%s: %s" % (coord, msg))

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 2.83 KB 0644
_ast_gen.py File 8.46 KB 0644
_build_tables.py File 851 B 0644
_c_ast.cfg File 4.08 KB 0644
ast_transforms.py File 3.48 KB 0644
c_ast.py File 22.79 KB 0644
c_generator.py File 13.25 KB 0644
c_lexer.py File 14.11 KB 0644
c_parser.py File 60.75 KB 0644
lextab.py File 7.08 KB 0644
plyparser.py File 1.56 KB 0644
yacctab.py File 123.33 KB 0644