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.
```
\..* -name-re-> !
__pycache__ -name-> !
.*\.md -name-re-> !
\..* -name-re-> !
__pycache__ -name-> !
.*\.md -name-re-> !
```

View File

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