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/invRegex.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/invRegex.py')
-rw-r--r-- | examples/invRegex.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/examples/invRegex.py b/examples/invRegex.py index aea3b55..e935b3b 100644 --- a/examples/invRegex.py +++ b/examples/invRegex.py @@ -1,4 +1,4 @@ -#
+#
# invRegex.py
#
# Copyright 2008, Paul McGuire
@@ -13,7 +13,7 @@ #
__all__ = ["count","invert"]
-from pyparsing import (Literal, oneOf, printables, ParserElement, Combine,
+from pyparsing import (Literal, oneOf, printables, ParserElement, Combine,
SkipTo, infixNotation, ParseFatalException, Word, nums, opAssoc,
Suppress, ParseResults, srange)
@@ -76,7 +76,7 @@ class AlternativeEmitter(object): for s in e.makeGenerator()():
yield s
return altGen
-
+
class LiteralEmitter(object):
def __init__(self,lit):
self.lit = lit
@@ -91,7 +91,7 @@ class LiteralEmitter(object): def handleRange(toks):
return CharacterRangeEmitter(srange(toks[0]))
-
+
def handleRepetition(toks):
toks=toks[0]
if toks[1] in "*+":
@@ -111,7 +111,7 @@ def handleRepetition(toks): return GroupEmitter([toks[0]] * mincount + [opt])
else:
return [toks[0]] * mincount
-
+
def handleLiteral(toks):
lit = ""
for t in toks:
@@ -122,7 +122,7 @@ def handleLiteral(toks): lit += t[1]
else:
lit += t
- return LiteralEmitter(lit)
+ return LiteralEmitter(lit)
def handleMacro(toks):
macroChar = toks[0][1]
@@ -163,14 +163,14 @@ def parser(): repetition = (
( lbrace + Word(nums)("count") + rbrace ) |
( lbrace + Word(nums)("minCount")+","+ Word(nums)("maxCount") + rbrace ) |
- oneOf(list("*+?"))
+ oneOf(list("*+?"))
)
reRange.setParseAction(handleRange)
reLiteral.setParseAction(handleLiteral)
reMacro.setParseAction(handleMacro)
reDot.setParseAction(handleDot)
-
+
reTerm = ( reLiteral | reRange | reMacro | reDot | reNonCaptureGroup)
reExpr = infixNotation( reTerm,
[
@@ -180,7 +180,7 @@ def parser(): ]
)
_parser = reExpr
-
+
return _parser
def count(gen):
@@ -232,7 +232,7 @@ def main(): (Fri|Mon|S(atur|un)|T(hur|ue)s|Wednes)day
A(pril|ugust)|((Dec|Nov|Sept)em|Octo)ber|(Febr|Jan)uary|Ju(ly|ne)|Ma(rch|y)
""".split('\n')
-
+
for t in tests:
t = t.strip()
if not t: continue
|