Pseudo-code for parsing BCI-nf terms
We assume that in parsing, the parent pointer is passed around.
- If you parse something of the form (\x.M), create a lambda-node with the given parent pointer, child pointer the result of parsing M, character x, and leaf pointer (temporarily) null.
-
If you parse something of the form (MN), create an apply-node with the given parent pointer, left-child pointer the result of parsing M, right child pointer the result of parsing N. If the result of parsing M is a lambda-node, give an error message. The base-type character is temporarily null.
-
If you parse something of the form x, create a leaf node with the given parent pointer. Search upward for a lambda-node with variable x; if there is not one, or if its leaf pointer is not null, give an error message. Set the found lambda-node's leaf pointer to this node, and set this node's "points to" pointer to the found lambda-node. The base-type character is temporarily null.