diff options
| author | sanikoyes | 2017-10-30 19:59:11 +0800 |
|---|---|---|
| committer | Rémi Verschelde | 2017-11-20 23:24:52 +0100 |
| commit | fb801d4964fae52e3807e28f2cc5fcd940ce1700 (patch) | |
| tree | 8a3a2f1de45ad8f116ef42cd576a618bc4c4f8a6 /modules/gdscript/gdscript_parser.cpp | |
| parent | 24fe3bd605957ce803c0641a469dc3242c242238 (diff) | |
| download | godot-fb801d4964fae52e3807e28f2cc5fcd940ce1700.tar.gz godot-fb801d4964fae52e3807e28f2cc5fcd940ce1700.tar.zst godot-fb801d4964fae52e3807e28f2cc5fcd940ce1700.zip | |
Allow to extends constant variable
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
| -rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 1e677f11c..bee9ef199 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -2971,18 +2971,37 @@ void GDScriptParser::_parse_extends(ClassNode *p_class) { } while (true) { - if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER) { - _set_error("Invalid 'extends' syntax, expected string constant (path) and/or identifier (parent class)."); - return; - } + switch (tokenizer->get_token()) { + + case GDScriptTokenizer::TK_IDENTIFIER: { + + StringName identifier = tokenizer->get_token_identifier(); + p_class->extends_class.push_back(identifier); + } + break; + + case GDScriptTokenizer::TK_PERIOD: + break; + + default: { - StringName identifier = tokenizer->get_token_identifier(); - p_class->extends_class.push_back(identifier); + _set_error("Invalid 'extends' syntax, expected string constant (path) and/or identifier (parent class)."); + return; + } + } tokenizer->advance(1); - if (tokenizer->get_token() != GDScriptTokenizer::TK_PERIOD) - return; + + switch (tokenizer->get_token()) { + + case GDScriptTokenizer::TK_IDENTIFIER: + case GDScriptTokenizer::TK_PERIOD: + continue; + + default: + return; + } } } |
