# HG changeset patch # User catherine@Elli.myhome.westell.com # Date 1213991346 14400 # Node ID 37f471fb29b152a8906335014b3538e49420e850 # Parent 698710e88d1beff0fcbe3fe6ea16671974dfdf76 beginning to migrate line-ends to pyparsing diff -r 698710e88d1b -r 37f471fb29b1 cmd2.py --- 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