summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyparsing/core.py4
-rw-r--r--pyparsing/diagram/__init__.py4
-rw-r--r--pyparsing/helpers.py9
-rw-r--r--pyparsing/util.py8
4 files changed, 13 insertions, 12 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py
index b9e63af..95fa18f 100644
--- a/pyparsing/core.py
+++ b/pyparsing/core.py
@@ -2606,9 +2606,7 @@ class Word(Token):
self.mayIndexError = False
self.asKeyword = asKeyword
- if " " not in self.initChars | self.bodyChars and (
- min == 1 and exact == 0
- ):
+ if " " not in self.initChars | self.bodyChars and (min == 1 and exact == 0):
if self.bodyChars == self.initChars:
if max == 0:
repeat = "+"
diff --git a/pyparsing/diagram/__init__.py b/pyparsing/diagram/__init__.py
index ce84e8e..7d1c2ef 100644
--- a/pyparsing/diagram/__init__.py
+++ b/pyparsing/diagram/__init__.py
@@ -466,7 +466,9 @@ def _to_diagram_element(
# detect And's created with ``expr*N`` notation - for these use a OneOrMore with a repeat
# (all will have the same name, and resultsName)
if len(set((e.name, e.resultsName) for e in exprs)) == 1:
- ret = EditablePartial.from_call(railroad.OneOrMore, item="", repeat=str(len(exprs)))
+ ret = EditablePartial.from_call(
+ railroad.OneOrMore, item="", repeat=str(len(exprs))
+ )
elif _should_vertical(vertical, len(exprs)):
ret = EditablePartial.from_call(railroad.Stack, items=[])
else:
diff --git a/pyparsing/helpers.py b/pyparsing/helpers.py
index 5988f3e..f203111 100644
--- a/pyparsing/helpers.py
+++ b/pyparsing/helpers.py
@@ -763,6 +763,7 @@ def infix_notation(
def parseImpl(self, instring, loc, doActions=True):
self.expr.try_parse(instring, loc)
return loc, []
+
_FB.__name__ = "FollowedBy>"
ret = Forward()
@@ -792,18 +793,14 @@ def infix_notation(
thisExpr = Forward().set_name(term_name)
if rightLeftAssoc is OpAssoc.LEFT:
if arity == 1:
- matchExpr = _FB(lastExpr + opExpr) + Group(
- lastExpr + opExpr[1, ...]
- )
+ matchExpr = _FB(lastExpr + opExpr) + Group(lastExpr + opExpr[1, ...])
elif arity == 2:
if opExpr is not None:
matchExpr = _FB(lastExpr + opExpr + lastExpr) + Group(
lastExpr + (opExpr + lastExpr)[1, ...]
)
else:
- matchExpr = _FB(lastExpr + lastExpr) + Group(
- lastExpr[2, ...]
- )
+ matchExpr = _FB(lastExpr + lastExpr) + Group(lastExpr[2, ...])
elif arity == 3:
matchExpr = _FB(
lastExpr + opExpr1 + lastExpr + opExpr2 + lastExpr
diff --git a/pyparsing/util.py b/pyparsing/util.py
index 009c479..07d8dc7 100644
--- a/pyparsing/util.py
+++ b/pyparsing/util.py
@@ -206,12 +206,16 @@ def _collapseStringToRanges(s, re_escape=True):
if len(s) > 3:
for _, chars in itertools.groupby(s, key=is_consecutive):
first = last = next(chars)
- last = collections.deque(itertools.chain(iter([last]), chars), maxlen=1).pop()
+ last = collections.deque(
+ itertools.chain(iter([last]), chars), maxlen=1
+ ).pop()
if first == last:
ret.append(escape_re_range_char(first))
else:
ret.append(
- "{}-{}".format(escape_re_range_char(first), escape_re_range_char(last))
+ "{}-{}".format(
+ escape_re_range_char(first), escape_re_range_char(last)
+ )
)
else:
ret = [escape_re_range_char(c) for c in s]