/***************************************************************************
ASTNode.cpp
Base class for all the nodes in the AST.
-------------------
begin : Tue Jun 25 09:52:11 CEST 2002
copyright : (C) 2002 by Manuel Astudillo
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
#include "ASTNode.h"
#include "Terminal.h"
ASTNode::~ASTNode () {
for (unsigned int i = 0; i < children.size (); i++) {
delete children[i];
}
}
void ASTNode::init (const Symbol *s, ASTNode *parent) {
m_line = s->line;
m_col = s->col;
if (s->type == NON_TERMINAL) {
m_image = s->symbol;
} else {
m_image = ((Terminal*) s)->image;
}
m_symbol = s->symbol;
m_parent = parent;
}
void ASTNode::setImage (wstring image) {
m_image = image;
}
void ASTNode::setSymbol (wstring symbol) {
m_symbol = symbol;
}
wstring ASTNode::getImage () {
return m_image;
}
wstring ASTNode::getSymbol () {
return m_symbol;
}
void ASTNode::addChild (ASTNode *child) {
children.push_back (child);
}
vector