Files
kraken/src/ASTData.cpp

72 lines
1.5 KiB
C++
Raw Normal View History

#include "ASTData.h"
2013-10-16 01:43:18 -04:00
ASTData::ASTData() {
this->type = undef;
2013-10-16 01:43:18 -04:00
}
ASTData::ASTData(ASTType type, Type valueType) {
this->type = type;
this->valueType = valueType;
}
ASTData::ASTData(ASTType type, Symbol symbol, Type valueType) {
this->type = type;
this->valueType = valueType;
this->symbol = symbol;
}
ASTData::~ASTData() {
}
std::string ASTData::toString() {
return ASTTypeToString(type) + (symbol.isTerminal() ? " " + symbol.toString() : "") + " " + valueType.toString();
2013-10-16 01:43:18 -04:00
}
std::string ASTData::ASTTypeToString(ASTType type) {
switch (type) {
case translation_unit:
return "translation_unit";
case interpreter_directive:
return "interpreter_directive";
case identifier:
return "identifier";
case import:
return "import";
case function:
return "function";
case code_block:
return "code_block";
case typed_parameter:
return "typed_parameter";
case expression:
return "expression";
case boolean_expression:
return "boolean_expression";
case statement:
return "statement";
case if_statement:
return "if_statement";
case while_loop:
return "while_loop";
case for_loop:
return "for_loop";
2013-10-16 01:43:18 -04:00
case return_statement:
return "return_statement";
case assignment_statement:
return "assignment_statement";
case declaration_statement:
return "declaration_statement";
case if_comp:
return "if_comp";
case simple_passthrough:
return "simple_passthrough";
2013-10-16 01:43:18 -04:00
case function_call:
return "function_call";
case value:
return "value";
default:
return "unknown_ASTType";
}
}