Begin and End provide iterators for visiting every node in the tree in a top-to-bottom, left-to-right descent. It is the basis for the Tag and Terminal iterators.
LVParseTree::Iterator Begin ()
LVParseTree::Iterator End ()
The following code prints out every node in a parse tree.
LVParseTree::Iterator Itr = Tree.Begin();
LVParseTree::Iterator End = Tree.End();
for (; Itr != End; Itr++)
{
for (int i = 0; i < Itr->Level(); ++i) cout << "\t";
if (Itr->IsRule())
cout << "$" << Itr->RuleName() << ":" << endl;
if (Itr->IsTag())
cout << "{" << Itr->Text() << "}" << endl;
if (Itr->IsTerminal())
cout << "\"" << Itr->Text() << "\"" << endl;
}
If the grammar was the top level navigation example grammar, and the engine recognized "go back", the above code would print out:
$directive:
"go"
"back"
{$ = "APPLICATION_BACK"}
LVParseTree_GetIteratorBegin and LVParseTree_GetIteratorEnd (C API)
Complete Help Topic List | Speech Engine Product Information