Wednesday, January 25, 2012

[zpuvhspk] Parsing a tree

Given a set of tokens already organized into a tree, parse it into a syntax tree.  This is in contrast to a traditional parser which takes in a linear sequence of tokens.

On one hand, this seems an easier task.  On the other, one could do "harder" context-sensitive stuff more straightforwardly.

One subroutine will probably be to run a linear parser across siblings, and maybe recursively descend.

Ad hoc ways probably work, but it would be nice to have some theoretical or organized foundation, like the beautiful theory of LL(k), LR, and so forth.

Inspired by Lisp-like sugaring of other computer languages.  Currently I flatten it with linear tokens "(" and ")" and use a LALR parser.

No comments :