Allow spaces after ; for separated rolls
This commit is contained in:
parent
50fbbbfedd
commit
93761df5ed
|
@ -31,14 +31,15 @@ class Dice(Module):
|
||||||
|
|
||||||
"""Roll simple or complex dice strings."""
|
"""Roll simple or complex dice strings."""
|
||||||
|
|
||||||
tokens = ['NUMBER', 'TEXT']
|
tokens = ['NUMBER', 'TEXT', 'ROLLSEP']
|
||||||
literals = ['#', '/', '+', '-', 'd', ';']
|
literals = ['#', '/', '+', '-', 'd']
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
lex.lex(module=self)
|
lex.lex(module=self)
|
||||||
yacc.yacc(module=self)
|
yacc.yacc(module=self)
|
||||||
|
|
||||||
t_TEXT = r'\s+[^;]+'
|
t_TEXT = r'\s+[^;]+'
|
||||||
|
t_ROLLSEP = r';\s*'
|
||||||
|
|
||||||
def t_NUMBER(self, t):
|
def t_NUMBER(self, t):
|
||||||
r'\d+'
|
r'\d+'
|
||||||
|
@ -49,7 +50,7 @@ class Dice(Module):
|
||||||
t.lexer.skip(1)
|
t.lexer.skip(1)
|
||||||
|
|
||||||
precedence = (
|
precedence = (
|
||||||
('left', ';'),
|
('left', 'ROLLSEP'),
|
||||||
('left', '+', '-'),
|
('left', '+', '-'),
|
||||||
('right', 'd'),
|
('right', 'd'),
|
||||||
('left', '#'),
|
('left', '#'),
|
||||||
|
@ -141,7 +142,7 @@ class Dice(Module):
|
||||||
# have a comment that describes the roll
|
# have a comment that describes the roll
|
||||||
# Multiple roll strings can be chained with semicolon
|
# Multiple roll strings can be chained with semicolon
|
||||||
|
|
||||||
'roll : roll ";" roll'
|
'roll : roll ROLLSEP roll'
|
||||||
global output
|
global output
|
||||||
p[0] = p[1] + "; " + p[3]
|
p[0] = p[1] + "; " + p[3]
|
||||||
output = p[0]
|
output = p[0]
|
||||||
|
|
Loading…
Reference in New Issue