Mercurial > python-cmd2
comparison cmd2.py @ 167:a38303571916
trying to change ignores
author | catherine@dellzilla |
---|---|
date | Mon, 08 Dec 2008 17:44:08 -0500 |
parents | a3414ac38677 |
children | 786ab5a83eea |
comparison
equal
deleted
inserted
replaced
166:a3414ac38677 | 167:a38303571916 |
---|---|
224 self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result)) | 224 self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result)) |
225 | 225 |
226 commentGrammars = pyparsing.Or([pyparsing.pythonStyleComment, pyparsing.cStyleComment]) | 226 commentGrammars = pyparsing.Or([pyparsing.pythonStyleComment, pyparsing.cStyleComment]) |
227 commentGrammars.addParseAction(lambda x: '') | 227 commentGrammars.addParseAction(lambda x: '') |
228 commentInProgress = pyparsing.Literal('/*') + pyparsing.SkipTo(pyparsing.stringEnd) | 228 commentInProgress = pyparsing.Literal('/*') + pyparsing.SkipTo(pyparsing.stringEnd) |
229 quotedStringInProgress = pyparsing.Literal('"') ^ pyparsing.Literal("'") + pyparsing.SkipTo(pyparsing.stringEnd) | |
229 terminators = [';', '\n\n'] | 230 terminators = [';', '\n\n'] |
230 multilineCommands = [] | 231 multilineCommands = [] |
231 | 232 |
232 def _init_parser(self): | 233 def _init_parser(self): |
233 ''' | 234 ''' |
394 ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser).setParseAction(lambda x:x[0].strip())('args'))('statement') + | 395 ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser).setParseAction(lambda x:x[0].strip())('args'))('statement') + |
395 pyparsing.Optional(terminatorParser) + afterElements) | 396 pyparsing.Optional(terminatorParser) + afterElements) |
396 ) | 397 ) |
397 self.commentGrammars.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).setParseAction(lambda x: '') | 398 self.commentGrammars.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).setParseAction(lambda x: '') |
398 self.commentInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(pyparsing.cStyleComment) | 399 self.commentInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(pyparsing.cStyleComment) |
399 self.parser.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(self.commentGrammars).ignore(self.commentInProgress) | 400 self.quotedStringInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString) |
401 self.parser.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(self.commentGrammars).ignore(self.commentInProgress).ignore(self.quotedStringInProgress) | |
400 | 402 |
401 inputMark = pyparsing.Literal('<') | 403 inputMark = pyparsing.Literal('<') |
402 inputMark.setParseAction(lambda x: '') | 404 inputMark.setParseAction(lambda x: '') |
403 inputFrom = pyparsing.Word(self.legalChars + '/\\')('inputFrom') | 405 inputFrom = pyparsing.Word(self.legalChars + '/\\')('inputFrom') |
404 inputFrom.setParseAction(lambda x: (x and open(x[0]).read()) or getPasteBuffer()) | 406 inputFrom.setParseAction(lambda x: (x and open(x[0]).read()) or getPasteBuffer()) |