summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcatherine devlin <catherine.devlin@gmail.com>2011-07-28 17:06:46 -0400
committercatherine devlin <catherine.devlin@gmail.com>2011-07-28 17:06:46 -0400
commit5755233a997c4a8898451b12f39b94248687da44 (patch)
treef8c78efa0ab319bec0e8260c86413dd644798704
parent18df3f2ea8bb4800c00dd4e4cd288b2b835b9fe0 (diff)
downloadcmd2-hg-5755233a997c4a8898451b12f39b94248687da44.tar.gz
use packrat
-rwxr-xr-xcmd2.py22
1 files changed, 1 insertions, 21 deletions
diff --git a/cmd2.py b/cmd2.py
index 850275f..2d4cc76 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -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.