Mercurial > python-cmd2
comparison cmd2.py @ 147:cda32481187c
streamlining parsing
author | catherine@dellzilla |
---|---|
date | Thu, 20 Nov 2008 14:49:15 -0500 |
parents | 9ffb01d8876f |
children | 01ad9cd681a7 |
comparison
equal
deleted
inserted
replaced
146:9ffb01d8876f | 147:cda32481187c |
---|---|
227 >>> print c.p2('command with args and terminator; and suffix').dump() | 227 >>> print c.p2('command with args and terminator; and suffix').dump() |
228 >>> print c.p2('command with args, terminator;sufx | piped').dump() | 228 >>> print c.p2('command with args, terminator;sufx | piped').dump() |
229 >>> print c.p2('simple | piped').dump() | 229 >>> print c.p2('simple | piped').dump() |
230 >>> print c.p2('output into > afile.txt').dump() | 230 >>> print c.p2('output into > afile.txt').dump() |
231 >>> print c.p2('output into;sufx | pipethrume plz > afile.txt').dump() | 231 >>> print c.p2('output into;sufx | pipethrume plz > afile.txt').dump() |
232 >>> print c.p2('output to paste buffer >> ').dump() | 232 >>> print c.p2('output to paste buffer >> ').dump() |
233 >>> print c.p2('ignore the /* commented | > */ stuff;') | |
233 ''' | 234 ''' |
234 outputParser = pyparsing.oneOf(['>>','>'])('output') | 235 outputParser = pyparsing.oneOf(['>>','>'])('output') |
235 terminatorParser = pyparsing.oneOf(self.terminators)('terminator') | 236 terminatorParser = pyparsing.oneOf(self.terminators)('terminator') |
236 (pyparsing.stringEnd ^ pyparsing.oneOf(self.terminators) ^ '\nEOF' ^ '|' ^ outputParser)('terminator') | 237 (pyparsing.stringEnd ^ pyparsing.oneOf(self.terminators) ^ '\nEOF' ^ '|' ^ outputParser)('terminator') |
237 statementParser = pyparsing.Combine(pyparsing.Word(pyparsing.printables)('command') + | 238 statementParser = pyparsing.Combine(pyparsing.Word(pyparsing.printables)('command') + |