changeset 151:2377461a35f3

bug is in Combine() - removed it
author catherine@Elli.myhome.westell.com
date Fri, 21 Nov 2008 06:14:25 -0500
parents cc569f68a478
children 693d11072e8e
files cmd2.py ignoreBug.py
diffstat 2 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Thu Nov 20 16:35:35 2008 -0500
+++ b/cmd2.py	Fri Nov 21 06:14:25 2008 -0500
@@ -235,10 +235,10 @@
         outputParser = pyparsing.oneOf(['>>','>'])('output')
         terminatorParser = pyparsing.oneOf(self.terminators)('terminator')
         (pyparsing.stringEnd ^ pyparsing.oneOf(self.terminators) ^ '\nEOF' ^ '|' ^ outputParser)('terminator')
-        statementParser = pyparsing.Combine(pyparsing.Word(pyparsing.printables)('command') +
-                                            pyparsing.SkipTo(terminatorParser ^ '\nEOF' ^ '|' ^ outputParser ^ pyparsing.stringEnd)('args') +
-                                            pyparsing.Optional(terminatorParser)
-                                           )('statement')
+        statementParser = (pyparsing.Word(pyparsing.printables)('command') +
+                           pyparsing.SkipTo(terminatorParser ^ '\nEOF' ^ '|' ^ outputParser ^ pyparsing.stringEnd)('args') +
+                           pyparsing.Optional(terminatorParser)
+                          )('statement')
         self.commentGrammars.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).setParseAction(lambda x: '')
         self.commentInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(pyparsing.cStyleComment)       
         parser = statementParser + \
--- a/ignoreBug.py	Thu Nov 20 16:35:35 2008 -0500
+++ b/ignoreBug.py	Fri Nov 21 06:14:25 2008 -0500
@@ -1,8 +1,11 @@
-import pyparsing
-statementParser = pyparsing.Combine(pyparsing.Word(pyparsing.printables)('command') +
-                                            pyparsing.SkipTo('|' ^ pyparsing.stringEnd)('args') 
-                                           )('statement')
-print statementParser.parseString('hello there /* you | fish */ box').dump()
-statementParser.ignore(pyparsing.cStyleComment)
-print statementParser.parseString('hello there /* you | fish */ box').dump()
-                       
\ No newline at end of file
+from pyparsing import *
+
+teststr = 'please /* ignoreme: | oops */ findme: | kthx'
+parser = Word(printables)('leadWord') + SkipTo('|')('statement')
+print parser.parseString(teststr).statement
+parser.ignore(cStyleComment)
+print parser.parseString(teststr).statement
+parser = Combine(parser)
+print parser.parseString(teststr).statement
+parser.ignore(cStyleComment)
+print parser.parseString(teststr).statement