changeset 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 698710e88d1b
children 682588392eaf
files cmd2.py
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
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