diff options
author | catherine devlin <catherine.devlin@gmail.com> | 2011-07-28 17:06:46 -0400 |
---|---|---|
committer | catherine devlin <catherine.devlin@gmail.com> | 2011-07-28 17:06:46 -0400 |
commit | 5755233a997c4a8898451b12f39b94248687da44 (patch) | |
tree | f8c78efa0ab319bec0e8260c86413dd644798704 | |
parent | 18df3f2ea8bb4800c00dd4e4cd288b2b835b9fe0 (diff) | |
download | cmd2-hg-5755233a997c4a8898451b12f39b94248687da44.tar.gz |
use packrat
-rwxr-xr-x | cmd2.py | 22 |
1 files changed, 1 insertions, 21 deletions
@@ -41,6 +41,7 @@ import copy from code import InteractiveConsole, InteractiveInterpreter from optparse import make_option import pyparsing +pyparsing.ParserElement.enablePackrat() __version__ = '0.6.3' @@ -251,27 +252,6 @@ class ParsedString(str): 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. |