forked from zgrep/happybot
Now with more weirdness.
This commit is contained in:
parent
7012e5d024
commit
b0f6ccd7bd
1 changed files with 8 additions and 2 deletions
10
xplace/x.py
10
xplace/x.py
|
@ -17,7 +17,7 @@ parser = Lark(r'''
|
||||||
| //
|
| //
|
||||||
|
|
||||||
numrange : DIGITS
|
numrange : DIGITS
|
||||||
| DIGITS "-" DIGITS
|
| DIGITS "-" DIGITS [ "*" DIGITS ] [ "+" DIGITS ]
|
||||||
|
|
||||||
?unit : parens | brackets | char
|
?unit : parens | brackets | char
|
||||||
?concat_func : unit
|
?concat_func : unit
|
||||||
|
@ -125,6 +125,12 @@ class Expand(Transformer):
|
||||||
b = a
|
b = a
|
||||||
else:
|
else:
|
||||||
b = int(args[1].value)
|
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:
|
while a < b:
|
||||||
result.append(a)
|
result.append(a)
|
||||||
a += 1
|
a += 1
|
||||||
|
@ -132,7 +138,7 @@ class Expand(Transformer):
|
||||||
result.append(a)
|
result.append(a)
|
||||||
a -= 1
|
a -= 1
|
||||||
result.append(a)
|
result.append(a)
|
||||||
return result
|
return [ x * m + p for x in result ]
|
||||||
|
|
||||||
def index(self, args):
|
def index(self, args):
|
||||||
result, x = [], args[0]
|
result, x = [], args[0]
|
||||||
|
|
Loading…
Reference in a new issue