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
commitc6a3d22573f9ef6dbc0051b0fc740dc5e0dd565c (patch)
treef8c78efa0ab319bec0e8260c86413dd644798704
parent092e1141773756e84a6b2e7850e817cdf138b8f5 (diff)
downloadcmd2-git-c6a3d22573f9ef6dbc0051b0fc740dc5e0dd565c.tar.gz
use packrat
-rwxr-xr-xcmd2.py22
1 files changed, 1 insertions, 21 deletions
diff --git a/cmd2.py b/cmd2.py
index 850275f4..2d4cc76b 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.