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 | c6a3d22573f9ef6dbc0051b0fc740dc5e0dd565c (patch) | |
| tree | f8c78efa0ab319bec0e8260c86413dd644798704 | |
| parent | 092e1141773756e84a6b2e7850e817cdf138b8f5 (diff) | |
| download | cmd2-git-c6a3d22573f9ef6dbc0051b0fc740dc5e0dd565c.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. |
