Allow variable whitespace in arrow rules

This commit is contained in:
Joscha 2021-05-15 15:13:34 +02:00
parent f897d7c2e1
commit a6fdf05ee9
2 changed files with 11 additions and 5 deletions

View File

@ -285,7 +285,7 @@ For this task, the name arrows can be used. They are variants of the normal
arrows that only look at the file name instead of the entire path. arrows that only look at the file name instead of the entire path.
``` ```
\..* -name-re-> ! \..* -name-re-> !
__pycache__ -name-> ! __pycache__ -name-> !
.*\.md -name-re-> ! .*\.md -name-re-> !
``` ```

View File

@ -255,6 +255,12 @@ def parse_arrow(line: Line) -> str:
return "".join(name) return "".join(name)
def parse_whitespace(line: Line) -> None:
line.expect(" ")
while line.get() == " ":
line.advance()
def parse_rule(line: Line) -> Rule: def parse_rule(line: Line) -> Rule:
# Parse left side # Parse left side
leftindex = line.index leftindex = line.index
@ -264,13 +270,13 @@ def parse_rule(line: Line) -> Rule:
raise RuleParseException(line, "Left side can't be '!'") raise RuleParseException(line, "Left side can't be '!'")
# Parse arrow # Parse arrow
line.expect(" ") parse_whitespace(line)
arrowindex = line.index arrowindex = line.index
arrowname = parse_arrow(line) arrowname = parse_arrow(line)
# Parse right side # Parse right side
if line.get(): if line.get():
line.expect(" ") parse_whitespace(line)
right = parse_string(line) right = parse_string(line)
else: else:
right = False right = False