summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2016-08-27 15:56:51 +0300
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>2016-08-27 15:56:51 +0300
commit88430f0962403779670c3e82bbbc3ef3f6022169 (patch)
tree04eda12403e0c66d379a804324266aec031246c5 /modules/gdscript
parent4ee82a2c38c57fb980df1ed4727d47959ba9e983 (diff)
Add enum naming, by assinging a given enum's values to a Dict
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gd_parser.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index ed3bfd7ce2..4a32bec73a 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -3161,8 +3161,14 @@ void GDParser::_parse_class(ClassNode *p_class) {
//mutiple constant declarations..
int last_assign = -1; // Incremented by 1 right before the assingment.
+ String enum_name;
+ Dictionary enum_dict;
tokenizer->advance();
+ if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER) {
+ enum_name=tokenizer->get_token_identifier();
+ tokenizer->advance();
+ }
if (tokenizer->get_token()!=GDTokenizer::TK_CURLY_BRACKET_OPEN) {
_set_error("Expected '{' in enum declaration");
return;
@@ -3231,10 +3237,24 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
+ if(enum_name != "") {
+ const ConstantNode *cn = static_cast<const ConstantNode*>(constant.expression);
+ enum_dict[constant.identifier] = cn->value;
+ }
+
p_class->constant_expressions.push_back(constant);
}
}
+
+ if(enum_name != "") {
+ ClassNode::Constant enum_constant;
+ enum_constant.identifier=enum_name;
+ ConstantNode *cn = alloc_node<ConstantNode>();
+ cn->value = enum_dict;
+ enum_constant.expression=cn;
+ p_class->constant_expressions.push_back(enum_constant);
+ }
if (!_end_statement()) {
_set_error("Expected end of statement (enum)");