Mercurial > python-cmd2
changeset 168:786ab5a83eea
quotes still getting snipped, ugh
author | catherine@dellzilla |
---|---|
date | Mon, 08 Dec 2008 17:58:37 -0500 |
parents | a38303571916 |
children | 429c8e984df4 |
files | cmd2.py example/exampleSession.txt |
diffstat | 2 files changed, 19 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd2.py Mon Dec 08 17:44:08 2008 -0500 +++ b/cmd2.py Mon Dec 08 17:58:37 2008 -0500 @@ -378,6 +378,11 @@ multilineCommand = pyparsing.Or([pyparsing.Keyword(c, caseless=self.caseInsensitive) for c in self.multilineCommands])('multilineCommand') oneLineCommand = pyparsing.Word(self.legalChars)('command') pipe = pyparsing.Keyword('|', identChars='|') + self.commentGrammars.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).setParseAction(lambda x: '') + self.commentInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(pyparsing.cStyleComment) + self.quotedStringInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString) + #for element in (terminatorParser, outputParser, pipe): + # element.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(self.commentGrammars).ignore(self.commentInProgress).ignore(self.quotedStringInProgress) afterElements = \ pyparsing.Optional(pipe + pyparsing.SkipTo(outputParser ^ stringEnd)('pipeTo')) + \ pyparsing.Optional(outputParser + pyparsing.SkipTo(stringEnd).setParseAction(lambda x: x[0].strip())('outputTo')) @@ -395,11 +400,8 @@ ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser).setParseAction(lambda x:x[0].strip())('args'))('statement') + pyparsing.Optional(terminatorParser) + afterElements) ) - self.commentGrammars.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).setParseAction(lambda x: '') - self.commentInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(pyparsing.cStyleComment) - self.quotedStringInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString) - self.parser.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(self.commentGrammars).ignore(self.commentInProgress).ignore(self.quotedStringInProgress) - + self.parser.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(self.commentGrammars).ignore(self.commentInProgress).ignore(self.quotedStringInProgress) + inputMark = pyparsing.Literal('<') inputMark.setParseAction(lambda x: '') inputFrom = pyparsing.Word(self.legalChars + '/\\')('inputFrom')
--- a/example/exampleSession.txt Mon Dec 08 17:44:08 2008 -0500 +++ b/example/exampleSession.txt Mon Dec 08 17:58:37 2008 -0500 @@ -2,6 +2,18 @@ Calling `example.py -t` runs it as a series of unit tests, verifying that the same output is still returned. +(Cmd) speak the /* hidden comment */ text +the text +(Cmd) speak the "unhidden quote" text +the "unhidden quote" text +(Cmd) speak "unhidden quote" text +"unhidden quote" text +(Cmd) orate "unhidden quote" text; +"unhidden quote" text +(Cmd) orate "not ; terminated; just; yet" +> now I end; +"not ; terminated; just; yet" +now I end (Cmd) help Documented commands (type help <topic>):