diff options
author | Paul McGuire <ptmcg@users.noreply.github.com> | 2018-12-23 21:30:40 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-23 21:30:40 -0600 |
commit | 4fba64a079016e6ea62d041f19b7eadd081341e8 (patch) | |
tree | 6c5fdae41cf8b335ff1c64f37856786523e4fd0d /examples/pythonGrammarParser.py | |
parent | 59dfd314c23fd653271bdad37631f0497e8ad748 (diff) | |
parent | de8326d00dffdb500c02839a98330b869c2457f3 (diff) | |
download | pyparsing-git-4fba64a079016e6ea62d041f19b7eadd081341e8.tar.gz |
Merge pull request #55 from jdufresne/ws
Trim trailing white space throughout the project
Diffstat (limited to 'examples/pythonGrammarParser.py')
-rw-r--r-- | examples/pythonGrammarParser.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/pythonGrammarParser.py b/examples/pythonGrammarParser.py index 706f758..aed6bbe 100644 --- a/examples/pythonGrammarParser.py +++ b/examples/pythonGrammarParser.py @@ -5,7 +5,7 @@ from pyparsing import *
-# should probably read this from the Grammar file provided with the Python source, but
+# should probably read this from the Grammar file provided with the Python source, but
# this just skips that step and inlines the bnf text directly - this grammar was taken from
# Python 2.4.1
#
@@ -135,15 +135,15 @@ class SemanticGroup(object): self.contents = contents
while self.contents[-1].__class__ == self.__class__:
self.contents = self.contents[:-1] + self.contents[-1].contents
-
+
def __str__(self):
- return "{}({})".format(self.label,
+ return "{}({})".format(self.label,
" ".join([isinstance(c,str) and c or str(c) for c in self.contents]) )
-
+
class OrList(SemanticGroup):
label = "OR"
pass
-
+
class AndList(SemanticGroup):
label = "AND"
pass
@@ -151,7 +151,7 @@ class AndList(SemanticGroup): class OptionalGroup(SemanticGroup):
label = "OPT"
pass
-
+
class Atom(SemanticGroup):
def __init__(self,contents):
if len(contents) > 1:
@@ -162,10 +162,10 @@ class Atom(SemanticGroup): self.contents = contents
else:
self.contents = contents[0]
-
+
def __str__(self):
return "{}{}".format(self.rep, self.contents)
-
+
def makeGroupObject(cls):
def groupAction(s,l,t):
try:
|