Files
kraken/src/ASTData.cpp

79 lines
1.7 KiB
C++
Raw Normal View History

#include "ASTData.h"
2013-10-16 01:43:18 -04:00
ASTData::ASTData() {
this->type = undef;
2014-01-07 13:14:58 -05:00
this->valueType = NULL;
2013-10-16 01:43:18 -04:00
}
2014-01-07 13:14:58 -05:00
ASTData::ASTData(ASTType type, Type *valueType) {
this->type = type;
this->valueType = valueType;
}
2014-01-07 13:14:58 -05:00
ASTData::ASTData(ASTType type, Symbol symbol, Type *valueType) {
this->type = type;
this->valueType = valueType;
this->symbol = symbol;
}
ASTData::~ASTData() {
}
std::string ASTData::toString() {
2014-02-18 21:55:00 -05:00
return ASTTypeToString(type) + " " +
(symbol.isTerminal() ? " " + symbol.toString() : "") + " " +
(valueType ? valueType->toString() : "no_type");
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";
2014-01-07 13:14:58 -05:00
case type_def:
return "type_def";
2013-10-16 01:43:18 -04:00
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";
2015-04-04 01:32:40 -04:00
case passthrough_params:
return "passthrough_params";
2013-10-16 01:43:18 -04:00
case function_call:
return "function_call";
case value:
return "value";
default:
return "unknown_ASTType";
}
}