/usr/lib/python2.6/site-packages/pycparser-2.14-py2.6.egg/pycparser
NameSizeModeActions
ply/-0755rm
ast_transforms.py35680755editdlrm
ast_transforms.pyc28910644editdlrm
c_ast.py233360755editdlrm
c_ast.pyc435420644editdlrm
c_generator.py135700755editdlrm
c_generator.pyc205930644editdlrm
c_lexer.py144470755editdlrm
c_lexer.pyc169800644editdlrm
c_parser.py622120755editdlrm
c_parser.pyc681880644editdlrm
lextab.py74570755editdlrm
lextab.pyc71340644editdlrm
plyparser.py15940755editdlrm
plyparser.pyc29080644editdlrm
yacctab.py1295680755editdlrm
yacctab.pyc1018710644editdlrm
_ast_gen.py86630755editdlrm
_ast_gen.pyc98050644editdlrm
_build_tables.py8510755editdlrm
_build_tables.pyc6620644editdlrm
_c_ast.cfg41800644editdlrm
__init__.py29030755editdlrm
__init__.pyc29720644editdlrm
Edit: /usr/lib/python2.6/site-packages/pycparser-2.14-py2.6.egg/pycparser/plyparser.py (1594B)
#----------------------------------------------------------------- # 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 _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))