Mercurial > python-cmd2
comparison cmd2.py @ 138:4b428849783d
pushing changeable ignores into __init__
author | catherine@dellzilla |
---|---|
date | Mon, 10 Nov 2008 16:46:41 -0500 |
parents | 308e99cebbb8 |
children | e49ded85ba4c |
comparison
equal
deleted
inserted
replaced
137:308e99cebbb8 | 138:4b428849783d |
---|---|
194 for p in (self.terminatorPattern, self.pipePattern, self.redirectInPattern, self.redirectOutPattern, self.punctuationPattern): | 194 for p in (self.terminatorPattern, self.pipePattern, self.redirectInPattern, self.redirectOutPattern, self.punctuationPattern): |
195 p.ignore(pyparsing.sglQuotedString) | 195 p.ignore(pyparsing.sglQuotedString) |
196 p.ignore(pyparsing.dblQuotedString) | 196 p.ignore(pyparsing.dblQuotedString) |
197 p.ignore(self.commentGrammars) | 197 p.ignore(self.commentGrammars) |
198 p.ignore(self.commentInProgress) | 198 p.ignore(self.commentInProgress) |
199 self.commentGrammars.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).setParseAction(lambda x: '') | |
200 self.commentInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(pyparsing.cStyleComment) | |
199 | 201 |
200 def do_shortcuts(self, args): | 202 def do_shortcuts(self, args): |
201 """Lists single-key shortcuts available.""" | 203 """Lists single-key shortcuts available.""" |
202 result = "\n".join('%s: %s' % (sc[0], sc[1]) for sc in self.shortcuts.items()) | 204 result = "\n".join('%s: %s' % (sc[0], sc[1]) for sc in self.shortcuts.items()) |
203 self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result)) | 205 self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result)) |
204 | 206 |
205 commentGrammars = pyparsing.Or([pyparsing.pythonStyleComment, pyparsing.cStyleComment]) | 207 commentGrammars = pyparsing.Or([pyparsing.pythonStyleComment, pyparsing.cStyleComment]) |
206 commentGrammars.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).setParseAction(lambda x: '') | |
207 commentInProgress = pyparsing.Literal('/*') + pyparsing.SkipTo(pyparsing.stringEnd) | 208 commentInProgress = pyparsing.Literal('/*') + pyparsing.SkipTo(pyparsing.stringEnd) |
208 commentInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(pyparsing.cStyleComment) | |
209 | 209 |
210 specialTerminators = {'/*': pyparsing.Literal('*/')('terminator') } | 210 specialTerminators = {'/*': pyparsing.Literal('*/')('terminator') } |
211 terminatorPattern = ((pyparsing.Literal(';') ^ pyparsing.Literal('\n\n')) | 211 terminatorPattern = ((pyparsing.Literal(';') ^ pyparsing.Literal('\n\n')) |
212 ^ (pyparsing.Literal('\nEOF') + pyparsing.lineEnd))('terminator') | 212 ^ (pyparsing.Literal('\nEOF') + pyparsing.lineEnd))('terminator') |
213 argSeparatorPattern = pyparsing.Word(pyparsing.printables)('command') \ | 213 argSeparatorPattern = pyparsing.Word(pyparsing.printables)('command') \ |