def _markproduction(self, prod, tree=None):
if tree is None: tree = self._tree
for i in range(len(tree.subtrees())-len(prod.rhs())):
if tree['color', i] == 'white':
self._markproduction
for j, node in enumerate(prod.rhs()):
widget = tree.subtrees()[i+j]
if (isinstance(node, Nonterminal) and
isinstance(widget, TreeSegmentWidget) and
node.symbol == widget.label().text()):
pass # matching nonterminal
elif (isinstance(node, compat.string_types) and
isinstance(widget, TextWidget) and
node == widget.text()):
pass # matching nonterminal
else: break
else:
# Everything matched!
print('MATCH AT', i)
#//////////////////////////////////////////////////
# Grammar
#//////////////////////////////////////////////////
评论列表
文章目录