X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/e74117f172e29e8a980e2c9de929ad50d3769150..65c5a0d9f180c4b36ea98917cb3b569f8e4f892f:/blib2to3/pgen2/parse.py diff --git a/blib2to3/pgen2/parse.py b/blib2to3/pgen2/parse.py index 6bebdbb..22f14c8 100644 --- a/blib2to3/pgen2/parse.py +++ b/blib2to3/pgen2/parse.py @@ -13,17 +13,20 @@ how this parsing engine works. # Local imports from . import token + class ParseError(Exception): """Exception to signal the parser is stuck.""" def __init__(self, msg, type, value, context): - Exception.__init__(self, "%s: type=%r, value=%r, context=%r" % - (msg, type, value, context)) + Exception.__init__( + self, "%s: type=%r, value=%r, context=%r" % (msg, type, value, context) + ) self.msg = msg self.type = type self.value = value self.context = context + class Parser(object): """Parser engine. @@ -108,7 +111,7 @@ class Parser(object): stackentry = (self.grammar.dfas[start], 0, newnode) self.stack = [stackentry] self.rootnode = None - self.used_names = set() # Aliased to self.rootnode.used_names in pop() + self.used_names = set() # Aliased to self.rootnode.used_names in pop() def addtoken(self, type, value, context): """Add a token; return True iff this is the end of the program.""" @@ -145,15 +148,14 @@ class Parser(object): if ilabel in itsfirst: # Push a symbol self.push(t, self.grammar.dfas[t], newstate, context) - break # To continue the outer while loop + break # To continue the outer while loop else: if (0, state) in arcs: # An accepting state, pop it and try something else self.pop() if not self.stack: # Done parsing, but another token is input - raise ParseError("too much input", - type, value, context) + raise ParseError("too much input", type, value, context) else: # No success finding a transition raise ParseError("bad input", type, value, context)