Browse
 
Tools
Rss Categories

LVParseTree_CreateTagIteratorBegin and LVParseTree_CreateTagIteratorEnd

Reference Number: AA-00960 Views: 1020 0 Rating/ Voters

LVParseTree_CreateTagIteratorBegin and LVParseTree_CreateTagIteratorEnd provide iterators for visiting the tags in the tree's body.

Functions

  • H_PARSE_TREE_TAG_ITR LVParseTree_CreateTagIteratorBegin(H_PARSE_TREE Tree)

    H_PARSE_TREE_TAG_ITR LVParseTree_CreateTagIteratorEnd(H_PARSE_TREE Tree)

Parameter

Tree

Handle to a parse tree.

Example

The following code prints out every tag in a parse tree.

C code

H_PARSE_TREE_TAG_ITR Itr;
H_PARSE_TREE_TAG_ITR End;
H_PARSE_TREE_NODE Node;

Itr = LVParseTree_CreateTagIteratorBegin(Tree);
End = LVParseTree_CreateTagIteratorEnd(Tree);

while (!LVParseTree_TagIterator_AreEqual(Itr,End))
{
Node = LVParseTree_TagIterator_GetNode(Itr);
printf("%s;\n",LVParseTree_Node_GetText(Node));
LVParseTree_TagIterator_Advance(Itr);
}

LVParseTree_TagIterator_Release(Itr);
LVParseTree_TagIterator_Release(End);

// Note: Node handles don't get released; They are part of the tree,
// and the tree releases them when it gets released

If the grammar was the top level navigation example grammar, and the engine recognized "go back", the the above code would print out:

out = "APPLICATION_BACK";

Remark

The TagIterator does not visit the tags in a tree's header. Use LVParseTree::HeaderTag to access the contents of those tags.

See Also