Skip to content

Commit d2ffc54

Browse files
committed
modified per hab's comment
1 parent 66d8d03 commit d2ffc54

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

ometa/interp.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ def end(self):
7171
def setNext(self, rule):
7272
if isinstance(rule, basestring):
7373
rule = (rule, )
74-
if not isinstance(rule, (list, tuple)):
75-
raise TypeError("rule should be a string, list or a tuple.")
74+
rule = tuple(rule)
7675
return self.apply(rule[0], None, rule[1:])
7776

7877

ometa/test/test_tube.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def setUp(self):
3434
_grammar = r"""
3535
delimiter = '\r\n'
3636
initial = <(~delimiter anything)*>:val delimiter -> receiver.receive(val)
37+
witharg :arg1 :arg2 = <(~delimiter anything)*>:a delimiter -> receiver.receive(arg1+arg2+a)
3738
"""
3839
self.grammar = self._parseGrammar(_grammar)
3940

@@ -75,3 +76,16 @@ def test_bindings(self):
7576
bindings = {'SMALL_INT': 3}
7677
TrampolinedParser(self._parseGrammar(grammar), receiver, bindings).receive('0')
7778
self.assertEqual(receiver.received, [3])
79+
80+
81+
def test_currentRuleWithArgs(self):
82+
"""
83+
TrampolinedParser should be able to invoke curruent rule with args.
84+
"""
85+
receiver = TrampolinedReceiver()
86+
receiver.currentRule = "witharg", "nice ", "day"
87+
trampolinedParser = TrampolinedParser(self.grammar, receiver, {})
88+
buf = b' oh yes\r\n'
89+
for c in iterbytes(buf):
90+
trampolinedParser.receive(c)
91+
self.assertEqual(receiver.received, ["nice day oh yes"])

0 commit comments

Comments
 (0)