Parser/QueryParser.cpp
void QueryParser::printTree(antlr4::tree::ParseTree *root, int dep)
{
	// Print tabs according to node's depth in tree
	for (int i = 0; i < dep; i++)
		cout << '-';

	string nodeTypeName = typeid(*root).name();
	size_t n = root->children.size();
	cout << "Type: " << nodeTypeName << ' ';
	cout << "Text: " << root->getText() << ' ';
	cout << "#Children: " << n << endl;

	for (size_t i = 0; i < n; i++)
	{
		antlr4::tree::ParseTree *childNode = root->children[i];
		printTree(childNode, dep + 1);
	}
}
/**
	Print the sub-parse-tree rooted at root.

	@param root pointer to the root of the sub-parse-tree.
	@param dep depth of the sub-parse-tree's root.
*/
Print the sub-parse-tree rooted at root.
Print the sub - parse - tree rooted at root .
void QueryParser::printTree(antlr4::tree::ParseTree *root, int dep)
{
	for (int i = 0; i < dep; i++)
		cout << '-';
	string nodeTypeName = typeid(*root).name();
	size_t n = root->children.size();
	cout << "Type: " << nodeTypeName << ' ';
	cout << "Text: " << root->getText() << ' ';
	cout << "#Children: " << n << endl;
	for (size_t i = 0; i < n; i++)
	{
		antlr4::tree::ParseTree *childNode = root->children[i];
		printTree(childNode, dep + 1);
	}
}
void QueryParser :: printTree ( antlr4 :: tree :: ParseTree * root , int dep ) { for ( int i = 0 ; i < dep ; i ++ ) cout << ' ' ; string nodeTypeName = typeid ( * root ) . name ( ) ; size_t n = root -> children . size ( ) ; cout << " " << nodeTypeName << ' ' ; cout << " " << root -> getText ( ) << ' ' ; cout << " " << n << endl ; for ( size_t i = 0 ; i < n ; i ++ ) { antlr4 :: tree :: ParseTree * childNode = root -> children [ i ] ; printTree ( childNode , dep + 1 ) ; } }
Print the sub-parse-tree rooted at root.
Print the sub - parse - tree rooted at root .
// Print tabs according to node's depth in tree