/**************************************************************************/ /* gdscript_parser.h */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* 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/io/resource.h" #include "core/object/ref_counted.h" #include "core/object/script_language.h" #include "core/string/string_name.h" #include "core/string/ustring.h" #include "core/templates/hash_map.h" #include "core/templates/list.h" #include "core/templates/rb_map.h" #include "core/templates/vector.h" #include "core/variant/variant.h" #include "gdscript_cache.h" #include "gdscript_tokenizer.h" #ifdef DEBUG_ENABLED #include "core/string/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 LambdaNode; 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; class DataType { private: // Private access so we can control memory management. DataType *container_element_type = nullptr; public: enum Kind { BUILTIN, NATIVE, SCRIPT, CLASS, // GDScript. ENUM, // Enumeration. VARIANT, // Can be any type. RESOLVING, // Currently resolving. UNRESOLVED, }; 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