forked from zgrep/happybot
forgot about "?"
This commit is contained in:
parent
f152c25877
commit
c24ab434fc
6
xed.py
6
xed.py
|
@ -13,7 +13,7 @@ parser = Lark(r'''
|
|||
| bracketliteral "-" bracketliteral
|
||||
brackets : "[" range+ "]" -> either
|
||||
|
||||
char : /[^\\\[\]\{\}\(\)\|\^~]/
|
||||
char : /[^\\\[\]\{\}\(\)\|\^~\?]/
|
||||
| "\\" /\D/
|
||||
| //
|
||||
|
||||
|
@ -23,6 +23,7 @@ parser = Lark(r'''
|
|||
?unit : parens | brackets | char
|
||||
?concat_func : unit
|
||||
| concat_func "{" DIGITS "}" -> concat_repeat
|
||||
| concat_func "?" -> zero_or_one
|
||||
| concat_func "~" -> reverse
|
||||
| concat_func "~" NUMBER -> roll
|
||||
| concat_func "~{" NUMBER ["," DIGITS] "}" -> roll
|
||||
|
@ -67,6 +68,9 @@ class Expand(Transformer):
|
|||
result.append(chr(a))
|
||||
return result
|
||||
|
||||
def zero_or_one(self, args):
|
||||
return self.either([[''], args[0]])
|
||||
|
||||
def either(self, args):
|
||||
result = []
|
||||
for x in args:
|
||||
|
|
Loading…
Reference in New Issue