comparison cmd2.py @ 60:682588392eaf

experiments with parsing in lineend
author catherine@Elli.myhome.westell.com
date Fri, 20 Jun 2008 19:52:39 -0400
parents 37f471fb29b1
children 4e028e9ec4c2
comparison
equal deleted inserted replaced
59:37f471fb29b1 60:682588392eaf
290 #inside a string? What about statements that end in different ways? 290 #inside a string? What about statements that end in different ways?
291 # + searching for EOF string is sloppy! 291 # + searching for EOF string is sloppy!
292 statementEndPattern = re.compile(r'[%s]\s*$' % terminators) 292 statementEndPattern = re.compile(r'[%s]\s*$' % terminators)
293 lineEndFinder = pyparsing.Optional(pyparsing.CharsNotIn(';')) + ';' 293 lineEndFinder = pyparsing.Optional(pyparsing.CharsNotIn(';')) + ';'
294 def statementHasEnded(self, lines): 294 def statementHasEnded(self, lines):
295 try: 295 #import pdb; pdb.set_trace()
296 lineEndFinder.parseString(lines) 296 try:
297 return True` 297 self.lineEndFinder.parseString(lines)
298 return True
298 except pyparsing.ParseException: 299 except pyparsing.ParseException:
299 return False 300 return False
300 ''' 301 '''
301 return bool(self.statementEndPattern.search(lines)) \ 302 return bool(self.statementEndPattern.search(lines)) \
302 or lines[-3:] == 'EOF' \ 303 or lines[-3:] == 'EOF' \