2013-09-26 15:16:58 -04:00
|
|
|
#include "ASTData.h"
|
|
|
|
|
|
2013-10-16 01:43:18 -04:00
|
|
|
ASTData::ASTData() {
|
2013-10-26 11:47:34 -04:00
|
|
|
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) {
|
2013-09-26 15:16:58 -04:00
|
|
|
this->type = type;
|
|
|
|
|
this->valueType = valueType;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-07 13:14:58 -05:00
|
|
|
ASTData::ASTData(ASTType type, Symbol symbol, Type *valueType) {
|
2013-09-26 15:16:58 -04:00
|
|
|
this->type = type;
|
|
|
|
|
this->valueType = valueType;
|
|
|
|
|
this->symbol = symbol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ASTData::~ASTData() {
|
|
|
|
|
}
|
2013-10-02 03:15:20 -04:00
|
|
|
|
|
|
|
|
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 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";
|
2013-12-18 18:05:21 -06:00
|
|
|
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";
|
2015-05-15 15:19:55 -04:00
|
|
|
case break_statement:
|
|
|
|
|
return "break_statement";
|
|
|
|
|
case continue_statement:
|
|
|
|
|
return "continue_statement";
|
|
|
|
|
case defer_statement:
|
|
|
|
|
return "defer_statement";
|
2013-10-16 01:43:18 -04:00
|
|
|
case assignment_statement:
|
|
|
|
|
return "assignment_statement";
|
2013-11-01 02:52:18 -04:00
|
|
|
case declaration_statement:
|
|
|
|
|
return "declaration_statement";
|
2013-12-22 01:34:59 -06:00
|
|
|
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";
|
2015-04-10 00:37:31 -04:00
|
|
|
case in_passthrough_params:
|
|
|
|
|
return "out_passthrough_params";
|
|
|
|
|
case param_assign:
|
|
|
|
|
return "param_assign";
|
|
|
|
|
case opt_string:
|
|
|
|
|
return "opt_string";
|
2013-10-16 01:43:18 -04:00
|
|
|
case function_call:
|
|
|
|
|
return "function_call";
|
|
|
|
|
case value:
|
|
|
|
|
return "value";
|
|
|
|
|
default:
|
|
|
|
|
return "unknown_ASTType";
|
|
|
|
|
}
|
2013-10-02 03:15:20 -04:00
|
|
|
}
|