Browse files

empty tuples are not added any more to the AST after validation.

That is, a validation method can return tuple() to indicate valid AST
node yet not add it to the tree.
  • Loading branch information...
1 parent dda792f commit b2ac0d5088f88494077d97df1ea9d12166ecb32d @bl0b committed Jan 9, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 jupyLR/stack.py
View
4 jupyLR/stack.py
@@ -9,6 +9,7 @@ def printlist(l, pfx):
class stack_item(object):
+
def __init__(self, prev, x):
self.prev = prev
self.data = x
@@ -26,6 +27,7 @@ def __str__(self):
class stack(object):
+
def __init__(self, A):
self.active = []
self.A = A
@@ -82,7 +84,7 @@ def reduce(self, node, ruleidx):
ast = tuple(chain([name], tokens))
ok = self.A.validate_ast(ast)
if ok is not None:
- ok = (ok,)
+ ok = (ok != tuple()) and (ok,) or tuple()
else:
ast = tokens
ok = ast

0 comments on commit b2ac0d5

Please sign in to comment.