Mercurial > python-cmd2
diff cmd2.py @ 59:37f471fb29b1
beginning to migrate line-ends to pyparsing
author | catherine@Elli.myhome.westell.com |
---|---|
date | Fri, 20 Jun 2008 15:49:06 -0400 |
parents | a791d615545c |
children | 682588392eaf |
line wrap: on
line diff
--- a/cmd2.py Mon Jun 09 12:09:10 2008 -0400 +++ b/cmd2.py Fri Jun 20 15:49:06 2008 -0400 @@ -285,12 +285,22 @@ statekeeper.restore() return stop - + + #TODO: This should be replaced by pyparsing. What if terminators come + #inside a string? What about statements that end in different ways? + # + searching for EOF string is sloppy! statementEndPattern = re.compile(r'[%s]\s*$' % terminators) + lineEndFinder = pyparsing.Optional(pyparsing.CharsNotIn(';')) + ';' def statementHasEnded(self, lines): + try: + lineEndFinder.parseString(lines) + return True` + except pyparsing.ParseException: + return False + ''' return bool(self.statementEndPattern.search(lines)) \ or lines[-3:] == 'EOF' \ - or self.parseRedirectors(lines)[1] + or self.parseRedirectors(lines)[1]''' def finishStatement(self, firstline): statement = firstline