aboutsummaryrefslogtreecommitdiff
path: root/modules/gdscript/gd_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gd_parser.cpp')
-rw-r--r--modules/gdscript/gd_parser.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 70659326e..c1c1f5d5a 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -1704,7 +1704,7 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static)
}
switch (token) {
- // dictionary
+ // array
case GDTokenizer::TK_BRACKET_OPEN: {
tokenizer->advance();
pattern->pt_type = GDParser::PatternNode::PT_ARRAY;
@@ -1759,7 +1759,7 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static)
pattern->bind = tokenizer->get_token_identifier();
tokenizer->advance();
} break;
- // array
+ // dictionary
case GDTokenizer::TK_CURLY_BRACKET_OPEN: {
tokenizer->advance();
pattern->pt_type = GDParser::PatternNode::PT_DICTIONARY;
@@ -1826,17 +1826,16 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static)
}
}
} break;
+ case GDTokenizer::TK_WILDCARD: {
+ tokenizer->advance();
+ pattern->pt_type = PatternNode::PT_WILDCARD;
+ } break;
// all the constants like strings and numbers
default: {
Node *value = _parse_and_reduce_expression(pattern, p_static);
if (error_set) {
return NULL;
}
- if (value->type == Node::TYPE_IDENTIFIER && static_cast<IdentifierNode*>(value)->name == "_") {
- // wildcard pattern
- pattern->pt_type = PatternNode::PT_WILDCARD;
- break;
- }
if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) {
_set_error("Only constant expressions or variables allowed in a pattern");
@@ -2578,7 +2577,7 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
Vector<Node*> args;
Vector<double> constants;
- bool constant=true;
+ bool constant=false;
for(int i=1;i<op->arguments.size();i++) {
args.push_back(op->arguments[i]);
@@ -2586,13 +2585,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
ConstantNode *c = static_cast<ConstantNode*>(op->arguments[i]);
if (c->value.get_type()==Variant::REAL || c->value.get_type()==Variant::INT) {
constants.push_back(c->value);
- } else {
- constant=false;
+ constant=true;
}
}
}
- if (args.size()>0 || args.size()<4) {
+ if (args.size()>0 && args.size()<4) {
if (constant) {