Exemplo n.º 1
0
	//////////////////////////////////////////////////////////////////////////
	// parse_tree
	//////////////////////////////////////////////////////////////////////////
	void parse_tree(token_vector &tokens, token_vector &tree, TokenType until)
	{
		while(! tokens.empty())
		{
			token_ptr token = tokens[0] ;
			tokens.erase(tokens.begin()) ;
			if (token->gettype() == TOKEN_TYPE_FOR)
			{
				token_vector children ;
				parse_tree(tokens, children, TOKEN_TYPE_ENDFOR) ;
				token->set_children(children) ;
			}
			else if (token->gettype() == TOKEN_TYPE_IF)
			{
				token_vector children ;
				parse_tree(tokens, children, TOKEN_TYPE_ENDIF) ;
				token->set_children(children) ;
			}
			else if (token->gettype() == until)
			{
				return ;
			}
			tree.push_back(token) ;
		}
	}
Exemplo n.º 2
0
	void TokenIf::set_children( token_vector &children )
	{
		m_children.clear() ;
		std::copy(children.begin(), children.end(), std::back_inserter(m_children)) ;
	}
Exemplo n.º 3
0
	void TokenIf::set_children( token_vector &children )
	{
		m_children.assign(children.begin(), children.end()) ;
	}