# HG changeset patch # User catherine@dellzilla # Date 1228777117 18000 # Node ID 786ab5a83eea42a136e616142e8e5208a02b5461 # Parent a383035719169adec9f1fb4a144d1dc83eea90b6 quotes still getting snipped, ugh diff -r a38303571916 -r 786ab5a83eea cmd2.py --- 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') diff -r a38303571916 -r 786ab5a83eea example/exampleSession.txt --- 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 ):