[hearts2] Double heart emoji increment things by two
This commit is contained in:
parent
8f4ff8e119
commit
20dfe64190
1 changed files with 12 additions and 1 deletions
|
@ -94,7 +94,7 @@ def leaders(n, top=True):
|
||||||
# GRAMMAR
|
# GRAMMAR
|
||||||
#
|
#
|
||||||
|
|
||||||
tokens = ('POP', 'NOP', 'NAME', 'WORD', 'STR')
|
tokens = ('POP', 'DPOP', 'NOP', 'NAME', 'WORD', 'STR')
|
||||||
|
|
||||||
def t_POP(t):
|
def t_POP(t):
|
||||||
r'\+\+|:((yellow|green|blue|purple)_)?heart:|<3|<3'
|
r'\+\+|:((yellow|green|blue|purple)_)?heart:|<3|<3'
|
||||||
|
@ -102,6 +102,12 @@ def t_POP(t):
|
||||||
t.value = 1
|
t.value = 1
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
def t_DPOP(t):
|
||||||
|
r':(two|revolving)_hearts:'
|
||||||
|
LOG.debug('t_DPOP {}'.format(t.value))
|
||||||
|
t.value = 2
|
||||||
|
return t
|
||||||
|
|
||||||
def t_NOP(t):
|
def t_NOP(t):
|
||||||
r'--|</3|:broken_heart:'
|
r'--|</3|:broken_heart:'
|
||||||
LOG.debug('t_NOP {}'.format(t.value))
|
LOG.debug('t_NOP {}'.format(t.value))
|
||||||
|
@ -191,6 +197,7 @@ def p_oplist_single(p):
|
||||||
|
|
||||||
def p_op(p):
|
def p_op(p):
|
||||||
'''op : POP
|
'''op : POP
|
||||||
|
| DPOP
|
||||||
| NOP'''
|
| NOP'''
|
||||||
p[0] = p[1]
|
p[0] = p[1]
|
||||||
LOG.debug('op: {}'.format(p[1]))
|
LOG.debug('op: {}'.format(p[1]))
|
||||||
|
@ -293,6 +300,10 @@ class TestHearts(unittest.TestCase):
|
||||||
self.check_result('abc :yellow_heart:', 'abc', 1)
|
self.check_result('abc :yellow_heart:', 'abc', 1)
|
||||||
self.check_result('<3 abc', 'abc', 1)
|
self.check_result('<3 abc', 'abc', 1)
|
||||||
|
|
||||||
|
def test_double_pops(self):
|
||||||
|
self.check_result('abc :two_hearts:', 'abc', 2)
|
||||||
|
self.check_result('abc :revolving_hearts:', 'abc', 2)
|
||||||
|
|
||||||
def test_nops(self):
|
def test_nops(self):
|
||||||
self.check_result('-- abc', 'abc', -1)
|
self.check_result('-- abc', 'abc', -1)
|
||||||
self.check_result(':broken_heart: abc', 'abc', -1)
|
self.check_result(':broken_heart: abc', 'abc', -1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue