/*************************************************************************/ /* gdscript_parser.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #ifndef GDSCRIPT_PARSER_H #define GDSCRIPT_PARSER_H #include "core/hash_map.h" #include "core/io/multiplayer_api.h" #include "core/list.h" #include "core/map.h" #include "core/reference.h" #include "core/resource.h" #include "core/script_language.h" #include "core/string_name.h" #include "core/ustring.h" #include "core/variant.h" #include "core/vector.h" #include "gdscript_cache.h" #include "gdscript_functions.h" #include "gdscript_tokenizer.h" #ifdef DEBUG_ENABLED #include "core/string_builder.h" #include "gdscript_warning.h" #endif // DEBUG_ENABLED class GDScriptParser { struct AnnotationInfo; public: // Forward-declare all parser nodes, to avoid ordering issues. struct AnnotationNode; struct ArrayNode; struct AssertNode; struct AssignmentNode; struct AwaitNode; struct BinaryOpNode; struct BreakNode; struct BreakpointNode; struct CallNode; struct CastNode; struct ClassNode; struct ConstantNode; struct ContinueNode; struct DictionaryNode; struct EnumNode; struct ExpressionNode; struct ForNode; struct FunctionNode; struct GetNodeNode; struct IdentifierNode; struct IfNode; struct LiteralNode; struct MatchNode; struct MatchBranchNode; struct ParameterNode; struct PassNode; struct PatternNode; struct PreloadNode; struct ReturnNode; struct SelfNode; struct SignalNode; struct SubscriptNode; struct SuiteNode; struct TernaryOpNode; struct TypeNode; struct UnaryOpNode; struct VariableNode; struct WhileNode; struct DataType { enum Kind { BUILTIN, NATIVE, SCRIPT, CLASS, // GDScript. ENUM, // Full enumeration. ENUM_VALUE, // Value from enumeration. VARIANT, // Can be any type. UNRESOLVED, // TODO: Enum }; Kind kind = UNRESOLVED; enum TypeSource { UNDETECTED, // Can be any type. INFERRED, // Has inferred type, but still dynamic. ANNOTATED_EXPLICIT, // Has a specific type annotated. ANNOTATED_INFERRED, // Has a static type but comes from the assigned value. }; TypeSource type_source = UNDETECTED; bool is_constant = false; bool is_meta_type = false; bool is_coroutine = false; // For function calls. Variant::Type builtin_type = Variant::NIL; StringName native_type; StringName enum_type; // Enum name or the value name in an enum. Ref