# Expression are simple when the text has been tokenized
# so lets do that
tokop = [('a',','),('b','.')]
for i in tokop.len() :
if tokop[i][1] == '.' : parent = parent.pevious()
parent.append(tokop[i][0])
This code is collect tokens by block level, nothing more. But it assumes that append maintains graph integrity, however the graph is stored.
Grammar is always block based, it is the decoding of all the syntax short cuts we use, and need. Dealing with that is simply painful.
The other point is that in a descend only graph, how do you find the previous parent? Launch another operator from the top that stops when the target is at the next block start, block counts work. It is a direct shot when the child index is known because you can skip down by block count, Homing in with log n steps. The site operator cannot let graph operations maintain stacks and jump up and down the graph, arbitrarily, that is a no no.
No comments:
Post a Comment