Date: 05 13, 2002 11:00:58 AM

# Table of Parse Tree Functions

The functions used to operate on parse trees have been listed here in table form for easy reference. For examples of these functions, refer to the individual function pages included in the Parse Tree Functions section.

The return types include: INT (integer), PNODE (parse tree node), STR (string), and VAR VALUES (variable values). NONE indicates nothing is returned.

FUNCTION NAME | RETURNS | DESCRIPTION
arraylength(VAR) | INT | Count number of values in given variable or expr. (Like a call-by-reference)
eltnode(elt_num) | PNODE | Fetch the first node that matched the nth element of a rule.
group(start_n,end_n,name_str) | PNODE | Perform a reduction in the @POST region. Replaces the old group action. (2.3.1.9 return the created node.)
inputrange(start_n,end_n) | STR | Return a substring of the input text as specified by start and end offsets.
inputrange(start_n,end_n,out_ostr) | BOOL | Print a range of chars from the input text to an output stream.
lasteltnode(elt_num) | PNODE | Fetch the last node that matched the nth element of a rule.
phrasetext() | STR | Fetch the text that matched the right hand side phrase of a rule. Analogous to $text.
phraseraw() | STR | Fetch the raw text that matched the right hand side phrase of a rule. Analogous to $raw
pncopyvars() pncopyvars(aPnode) pncopyvars(0) | NONE | Copy a node's variables to the suggested node of a rule match. Must be called from the POST Region and can be considered a new-style NLP++ action.
pndeletechilds(pnode) | NONE | Delete children of given pnode.
pninsert(name, pnode, after_n) | PNODE | Insert nonliteral node with name into parse tree. If after_n == 1, insert after pnode, else if 0 then before pnode.
pnmakevar(pnode, var_str, val) | NONE | Make a variable for a given pnode.
pnname(pnode) | STR | Fetch the name of a pnode.
pnnext(pnode) | PNODE | Fetch a pnode's right sibling, if any.
pnpushval(pnode, var_str, val) |  | Push a value onto pnode's variable. New in 2.7.3.2
pnprev(pnode) | PNODE | Fetch a pnode's left sibling, if any.
pnrename(pnode, str) | STR | Rename given pnode. Returns the interned name.
pnreplaceval | NONE | Replace the value of pnode's variable.
pnroot() | PNODE | Fetch the root of a parse tree.
pnrpushval(pnode, var_str, val) |  | Push a value onto end of pnode's variable. New in 2.7.3.2
pndown(pnode) | PNODE | Fetch the child of a parse tree node.
pnsingletdown(pnode) | PNODE | Fetch the child of a parse tree node, obeying rules about going down a "singlet chain." I.e., get child only if no branching and if not going past node with BASE flag set.
pnup(pnode) | PNODE | Fetch a pnode's parent, if any. Only leftmost pnode in a list has a parent.
pnvar(pnode, var_str) | ARRAY | Fetch a pnode's variable value(s).
pnvarnames(pnode) | ARRAY | Fetch a node's variable names as an array.
varinlist(var_str, elt_num) | ARRAY | Find var_str variable's value(s) in any pnode that matched elt_numth element

## See Also

Special Functions

Knowledge Base Functions

Formatting and I/O Functions

String Functions

Spelling Functions