More ways of writing
Sometimes prettier
This commit is contained in:
parent
3012df4ac6
commit
0354fbf4a4
2 changed files with 26 additions and 15 deletions
|
|
@ -1715,6 +1715,17 @@ class NothingRule(Rule):
|
|||
Nothing = NothingRule()
|
||||
|
||||
|
||||
def alt(*args: Rule) -> Rule:
|
||||
"""A rule that matches one of a series of alternatives.
|
||||
|
||||
(A helper function that combines its arguments into nested alternatives.)
|
||||
"""
|
||||
result = args[0]
|
||||
for rule in args[1:]:
|
||||
result = AlternativeRule(result, rule)
|
||||
return result
|
||||
|
||||
|
||||
def seq(*args: Rule) -> Rule:
|
||||
"""A rule that matches a sequence of rules.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue