comparison cmd2.py @ 277:b3702f5ed467 0.5.5

changes for sqlpython 1.6.7
author catherine@cordelia
date Fri, 07 Aug 2009 16:38:31 -0400
parents 9bcfa4f81825
children c6064bfd4d6c
comparison
equal deleted inserted replaced
276:9bcfa4f81825 277:b3702f5ed467
333 333
334 prefixParser = pyparsing.Empty() 334 prefixParser = pyparsing.Empty()
335 commentGrammars = pyparsing.Or([pyparsing.pythonStyleComment, pyparsing.cStyleComment]) 335 commentGrammars = pyparsing.Or([pyparsing.pythonStyleComment, pyparsing.cStyleComment])
336 commentGrammars.addParseAction(lambda x: '') 336 commentGrammars.addParseAction(lambda x: '')
337 commentInProgress = pyparsing.Literal('/*') + pyparsing.SkipTo(pyparsing.stringEnd) 337 commentInProgress = pyparsing.Literal('/*') + pyparsing.SkipTo(pyparsing.stringEnd)
338 commentInProgress = pyparsing.NoMatch()
338 terminators = [';'] 339 terminators = [';']
339 blankLinesAllowed = False 340 blankLinesAllowed = False
340 multilineCommands = [] 341 multilineCommands = []
341 342
342 def _init_parser(self): 343 def _init_parser(self):
521 self.multilineParser = (((self.multilineCommand ^ oneLineCommand) + SkipToLast(terminatorParser).setParseAction(lambda x: x[0].strip())('args') + terminatorParser)('statement') + 522 self.multilineParser = (((self.multilineCommand ^ oneLineCommand) + SkipToLast(terminatorParser).setParseAction(lambda x: x[0].strip())('args') + terminatorParser)('statement') +
522 pyparsing.SkipTo(outputParser ^ pipe ^ stringEnd).setParseAction(lambda x: x[0].strip())('suffix') + afterElements) 523 pyparsing.SkipTo(outputParser ^ pipe ^ stringEnd).setParseAction(lambda x: x[0].strip())('suffix') + afterElements)
523 self.multilineParser.ignore(self.commentInProgress) 524 self.multilineParser.ignore(self.commentInProgress)
524 self.singleLineParser = ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser).setParseAction(lambda x:x[0].strip())('args'))('statement') + 525 self.singleLineParser = ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser).setParseAction(lambda x:x[0].strip())('args'))('statement') +
525 pyparsing.Optional(terminatorParser) + afterElements) 526 pyparsing.Optional(terminatorParser) + afterElements)
526 #self.multilineParser = self.multilineParser.setResultsName('multilineParser') 527 self.multilineParser = self.multilineParser.setResultsName('multilineParser')
527 #self.singleLineParser = self.singleLineParser.setResultsName('singleLineParser') 528 self.singleLineParser = self.singleLineParser.setResultsName('singleLineParser')
528 #self.blankLineTerminationParser = self.blankLineTerminationParser.setResultsName('blankLineTerminatorParser') 529 self.blankLineTerminationParser = self.blankLineTerminationParser.setResultsName('blankLineTerminatorParser')
529 self.parser = self.prefixParser + ( 530 self.parser = self.prefixParser + (
530 stringEnd | 531 stringEnd |
531 self.multilineParser | 532 self.multilineParser |
532 self.singleLineParser | 533 self.singleLineParser |
533 self.blankLineTerminationParser | 534 self.blankLineTerminationParser |