LVParseTree_CreateTagIteratorBegin and

LVParseTree_CreateTagIteratorEnd

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

Functions

Parameter

Tree

Handle to a parse tree.

Example

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

  1. H_PARSE_TREE_TAG_ITR Itr;
  2. H_PARSE_TREE_TAG_ITR End;
  3. H_PARSE_TREE_NODE Node;
  4.  
  5. Itr = LVParseTree_CreateTagIteratorBegin(Tree);
  6. End = LVParseTree_CreateTagIteratorEnd(Tree);
  7.  
  8. while (!LVParseTree_TagIterator_AreEqual(Itr,End))
  9. {
  10. Node = LVParseTree_TagIterator_GetNode(Itr);
  11. printf("%s;\n",LVParseTree_Node_GetText(Node));
  12. LVParseTree_TagIterator_Advance(Itr);
  13. }
  14.  
  15. LVParseTree_TagIterator_Release(Itr);
  16. LVParseTree_TagIterator_Release(End);
  17.  
  18. // Note: Node handles don't get released; They are part of the tree,
  19. // 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

© 2012 LumenVox LLC. All rights reserved.