Now with more weirdness.

This commit is contained in:
zgrep 2018-08-14 10:51:02 -04:00
parent 7012e5d024
commit b0f6ccd7bd
1 changed files with 8 additions and 2 deletions

View File

@ -17,7 +17,7 @@ parser = Lark(r'''
| //
numrange : DIGITS
| DIGITS "-" DIGITS
| DIGITS "-" DIGITS [ "*" DIGITS ] [ "+" DIGITS ]
?unit : parens | brackets | char
?concat_func : unit
@ -125,6 +125,12 @@ class Expand(Transformer):
b = a
else:
b = int(args[1].value)
m = 1
if len(args) >= 3:
m = int(args[2].value)
p = 0
if len(args) >= 4:
p = int(args[3].value)
while a < b:
result.append(a)
a += 1
@ -132,7 +138,7 @@ class Expand(Transformer):
result.append(a)
a -= 1
result.append(a)
return result
return [ x * m + p for x in result ]
def index(self, args):
result, x = [], args[0]