# HG changeset patch # User catherine.devlin@gmail.com # Date 1311887206 14400 # Node ID 3c17dae50252acccf6da1e922906e6ebdd57c683 # Parent 05a44bf4b449491e84a1286ee7e6a0b1a97f6ef9 use packrat diff -r 05a44bf4b449 -r 3c17dae50252 cmd2.py --- a/cmd2.py Thu Jul 28 01:13:46 2011 -0400 +++ b/cmd2.py Thu Jul 28 17:06:46 2011 -0400 @@ -41,6 +41,7 @@ from code import InteractiveConsole, InteractiveInterpreter from optparse import make_option import pyparsing +pyparsing.ParserElement.enablePackrat() __version__ = '0.6.3' @@ -251,27 +252,6 @@ new.parsed.statement['args'] = newargs return new -class SkipToLast(pyparsing.SkipTo): - def parseImpl( self, instring, loc, doActions=True ): - self.original_includeMatch = self.includeMatch - self.includeMatch = True - original_loc = loc - oldpos = loc - accumulated = [] - while True: - try: - res = pyparsing.SkipTo.parseImpl(self, instring, loc, False) - oldpos = loc - accumulated.append(res) - loc = res[0] - except pyparsing.ParseException: - self.includeMatch = self.original_includeMatch - res = pyparsing.SkipTo.parseImpl(self, instring, oldpos, doActions) - newres = list(res) - newres[0] = res[0] + sum([r[0] for r in accumulated[:-1]]) - newres[1][0] = res[1][0] + ''.join([r[1][0] for r in accumulated[:-1]]) - return tuple(newres) - class StubbornDict(dict): '''Dictionary that tolerates many input formats. Create it with stubbornDict(arg) factory function.