changeset 138:4b428849783d

pushing changeable ignores into __init__
author catherine@dellzilla
date Mon, 10 Nov 2008 16:46:41 -0500
parents 308e99cebbb8
children e2d06e53d09c
files cmd2.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Mon Nov 10 16:44:14 2008 -0500
+++ b/cmd2.py	Mon Nov 10 16:46:41 2008 -0500
@@ -196,6 +196,8 @@
             p.ignore(pyparsing.dblQuotedString)
             p.ignore(self.commentGrammars)
             p.ignore(self.commentInProgress)
+        self.commentGrammars.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).setParseAction(lambda x: '')
+        self.commentInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(pyparsing.cStyleComment)    
         
     def do_shortcuts(self, args):
         """Lists single-key shortcuts available."""
@@ -203,9 +205,7 @@
         self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result))
 
     commentGrammars = pyparsing.Or([pyparsing.pythonStyleComment, pyparsing.cStyleComment])
-    commentGrammars.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).setParseAction(lambda x: '')
     commentInProgress  = pyparsing.Literal('/*') + pyparsing.SkipTo(pyparsing.stringEnd)
-    commentInProgress.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(pyparsing.cStyleComment)    
     
     specialTerminators = {'/*': pyparsing.Literal('*/')('terminator') }
     terminatorPattern = ((pyparsing.Literal(';') ^ pyparsing.Literal('\n\n'))