gdscript_parser.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. /*************************************************************************/
  2. /* gdscript_parser.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef GDSCRIPT_PARSER_H
  31. #define GDSCRIPT_PARSER_H
  32. #include "core/map.h"
  33. #include "core/object.h"
  34. #include "core/script_language.h"
  35. #include "gdscript_functions.h"
  36. #include "gdscript_tokenizer.h"
  37. struct GDScriptDataType;
  38. struct GDScriptWarning;
  39. class GDScriptParser {
  40. public:
  41. struct ClassNode;
  42. struct DataType {
  43. enum {
  44. BUILTIN,
  45. NATIVE,
  46. SCRIPT,
  47. GDSCRIPT,
  48. CLASS,
  49. UNRESOLVED
  50. } kind;
  51. bool has_type;
  52. bool is_constant;
  53. bool is_meta_type; // Whether the value can be used as a type
  54. bool infer_type;
  55. bool may_yield; // For function calls
  56. Variant::Type builtin_type;
  57. StringName native_type;
  58. Ref<Script> script_type;
  59. ClassNode *class_type;
  60. String to_string() const;
  61. bool operator==(const DataType &other) const {
  62. if (!has_type || !other.has_type) {
  63. return true; // Can be considered equal for parsing purpose
  64. }
  65. if (kind != other.kind) {
  66. return false;
  67. }
  68. switch (kind) {
  69. case BUILTIN: {
  70. return builtin_type == other.builtin_type;
  71. } break;
  72. case NATIVE: {
  73. return native_type == other.native_type;
  74. } break;
  75. case GDSCRIPT:
  76. case SCRIPT: {
  77. return script_type == other.script_type;
  78. } break;
  79. case CLASS: {
  80. return class_type == other.class_type;
  81. } break;
  82. case UNRESOLVED: {
  83. } break;
  84. }
  85. return false;
  86. }
  87. DataType() :
  88. kind(UNRESOLVED),
  89. has_type(false),
  90. is_constant(false),
  91. is_meta_type(false),
  92. infer_type(false),
  93. may_yield(false),
  94. builtin_type(Variant::NIL),
  95. class_type(nullptr) {}
  96. };
  97. struct Node {
  98. enum Type {
  99. TYPE_CLASS,
  100. TYPE_FUNCTION,
  101. TYPE_BUILT_IN_FUNCTION,
  102. TYPE_BLOCK,
  103. TYPE_IDENTIFIER,
  104. TYPE_TYPE,
  105. TYPE_CONSTANT,
  106. TYPE_ARRAY,
  107. TYPE_DICTIONARY,
  108. TYPE_SELF,
  109. TYPE_OPERATOR,
  110. TYPE_CONTROL_FLOW,
  111. TYPE_LOCAL_VAR,
  112. TYPE_CAST,
  113. TYPE_ASSERT,
  114. TYPE_BREAKPOINT,
  115. TYPE_NEWLINE,
  116. };
  117. Node *next;
  118. int line;
  119. int column;
  120. Type type;
  121. virtual DataType get_datatype() const { return DataType(); }
  122. virtual void set_datatype(const DataType &p_datatype) {}
  123. virtual ~Node() {}
  124. };
  125. struct FunctionNode;
  126. struct BlockNode;
  127. struct ConstantNode;
  128. struct LocalVarNode;
  129. struct OperatorNode;
  130. struct ClassNode : public Node {
  131. bool tool;
  132. StringName name;
  133. bool extends_used;
  134. bool classname_used;
  135. StringName extends_file;
  136. Vector<StringName> extends_class;
  137. DataType base_type;
  138. String icon_path;
  139. struct Member {
  140. PropertyInfo _export;
  141. #ifdef TOOLS_ENABLED
  142. Variant default_value;
  143. #endif
  144. StringName identifier;
  145. DataType data_type;
  146. StringName setter;
  147. StringName getter;
  148. int line;
  149. Node *expression;
  150. OperatorNode *initial_assignment;
  151. MultiplayerAPI::RPCMode rpc_mode;
  152. int usages;
  153. };
  154. struct Constant {
  155. Node *expression;
  156. DataType type;
  157. };
  158. struct Signal {
  159. StringName name;
  160. Vector<StringName> arguments;
  161. int emissions;
  162. int line;
  163. };
  164. Vector<ClassNode *> subclasses;
  165. Vector<Member> variables;
  166. Map<StringName, Constant> constant_expressions;
  167. Vector<FunctionNode *> functions;
  168. Vector<FunctionNode *> static_functions;
  169. Vector<Signal> _signals;
  170. BlockNode *initializer;
  171. BlockNode *ready;
  172. ClassNode *owner;
  173. //Vector<Node*> initializers;
  174. int end_line;
  175. ClassNode() {
  176. tool = false;
  177. type = TYPE_CLASS;
  178. extends_used = false;
  179. classname_used = false;
  180. end_line = -1;
  181. owner = nullptr;
  182. }
  183. };
  184. struct FunctionNode : public Node {
  185. bool _static;
  186. MultiplayerAPI::RPCMode rpc_mode;
  187. bool has_yield;
  188. bool has_unreachable_code;
  189. StringName name;
  190. DataType return_type;
  191. Vector<StringName> arguments;
  192. Vector<DataType> argument_types;
  193. Vector<Node *> default_values;
  194. BlockNode *body;
  195. #ifdef DEBUG_ENABLED
  196. Vector<int> arguments_usage;
  197. #endif // DEBUG_ENABLED
  198. virtual DataType get_datatype() const { return return_type; }
  199. virtual void set_datatype(const DataType &p_datatype) { return_type = p_datatype; }
  200. int get_required_argument_count() { return arguments.size() - default_values.size(); }
  201. FunctionNode() {
  202. type = TYPE_FUNCTION;
  203. _static = false;
  204. rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
  205. has_yield = false;
  206. has_unreachable_code = false;
  207. }
  208. };
  209. struct BlockNode : public Node {
  210. ClassNode *parent_class;
  211. BlockNode *parent_block;
  212. List<Node *> statements;
  213. Map<StringName, LocalVarNode *> variables;
  214. bool has_return;
  215. Node *if_condition; //tiny hack to improve code completion on if () blocks
  216. //the following is useful for code completion
  217. List<BlockNode *> sub_blocks;
  218. int end_line;
  219. BlockNode() {
  220. if_condition = nullptr;
  221. type = TYPE_BLOCK;
  222. end_line = -1;
  223. parent_block = nullptr;
  224. parent_class = nullptr;
  225. has_return = false;
  226. }
  227. };
  228. struct TypeNode : public Node {
  229. Variant::Type vtype;
  230. TypeNode() { type = TYPE_TYPE; }
  231. };
  232. struct BuiltInFunctionNode : public Node {
  233. GDScriptFunctions::Function function;
  234. BuiltInFunctionNode() { type = TYPE_BUILT_IN_FUNCTION; }
  235. };
  236. struct IdentifierNode : public Node {
  237. StringName name;
  238. BlockNode *declared_block; // Simplify lookup by checking if it is declared locally
  239. DataType datatype;
  240. virtual DataType get_datatype() const { return datatype; }
  241. virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
  242. IdentifierNode() {
  243. type = TYPE_IDENTIFIER;
  244. declared_block = nullptr;
  245. }
  246. };
  247. struct LocalVarNode : public Node {
  248. StringName name;
  249. Node *assign;
  250. OperatorNode *assign_op;
  251. int assignments;
  252. int usages;
  253. DataType datatype;
  254. virtual DataType get_datatype() const { return datatype; }
  255. virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
  256. LocalVarNode() {
  257. type = TYPE_LOCAL_VAR;
  258. assign = nullptr;
  259. assign_op = nullptr;
  260. assignments = 0;
  261. usages = 0;
  262. }
  263. };
  264. struct ConstantNode : public Node {
  265. Variant value;
  266. DataType datatype;
  267. virtual DataType get_datatype() const { return datatype; }
  268. virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
  269. ConstantNode() { type = TYPE_CONSTANT; }
  270. };
  271. struct ArrayNode : public Node {
  272. Vector<Node *> elements;
  273. DataType datatype;
  274. virtual DataType get_datatype() const { return datatype; }
  275. virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
  276. ArrayNode() {
  277. type = TYPE_ARRAY;
  278. datatype.has_type = true;
  279. datatype.kind = DataType::BUILTIN;
  280. datatype.builtin_type = Variant::ARRAY;
  281. }
  282. };
  283. struct DictionaryNode : public Node {
  284. struct Pair {
  285. Node *key;
  286. Node *value;
  287. };
  288. Vector<Pair> elements;
  289. DataType datatype;
  290. virtual DataType get_datatype() const { return datatype; }
  291. virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
  292. DictionaryNode() {
  293. type = TYPE_DICTIONARY;
  294. datatype.has_type = true;
  295. datatype.kind = DataType::BUILTIN;
  296. datatype.builtin_type = Variant::DICTIONARY;
  297. }
  298. };
  299. struct SelfNode : public Node {
  300. SelfNode() { type = TYPE_SELF; }
  301. };
  302. struct OperatorNode : public Node {
  303. enum Operator {
  304. //call/constructor operator
  305. OP_CALL,
  306. OP_PARENT_CALL,
  307. OP_YIELD,
  308. OP_IS,
  309. OP_IS_BUILTIN,
  310. //indexing operator
  311. OP_INDEX,
  312. OP_INDEX_NAMED,
  313. //unary operators
  314. OP_NEG,
  315. OP_POS,
  316. OP_NOT,
  317. OP_BIT_INVERT,
  318. //binary operators (in precedence order)
  319. OP_IN,
  320. OP_EQUAL,
  321. OP_NOT_EQUAL,
  322. OP_LESS,
  323. OP_LESS_EQUAL,
  324. OP_GREATER,
  325. OP_GREATER_EQUAL,
  326. OP_AND,
  327. OP_OR,
  328. OP_ADD,
  329. OP_SUB,
  330. OP_MUL,
  331. OP_DIV,
  332. OP_MOD,
  333. OP_SHIFT_LEFT,
  334. OP_SHIFT_RIGHT,
  335. OP_INIT_ASSIGN,
  336. OP_ASSIGN,
  337. OP_ASSIGN_ADD,
  338. OP_ASSIGN_SUB,
  339. OP_ASSIGN_MUL,
  340. OP_ASSIGN_DIV,
  341. OP_ASSIGN_MOD,
  342. OP_ASSIGN_SHIFT_LEFT,
  343. OP_ASSIGN_SHIFT_RIGHT,
  344. OP_ASSIGN_BIT_AND,
  345. OP_ASSIGN_BIT_OR,
  346. OP_ASSIGN_BIT_XOR,
  347. OP_BIT_AND,
  348. OP_BIT_OR,
  349. OP_BIT_XOR,
  350. //ternary operators
  351. OP_TERNARY_IF,
  352. OP_TERNARY_ELSE,
  353. };
  354. Operator op;
  355. Vector<Node *> arguments;
  356. DataType datatype;
  357. virtual DataType get_datatype() const { return datatype; }
  358. virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
  359. OperatorNode() { type = TYPE_OPERATOR; }
  360. };
  361. struct PatternNode : public Node {
  362. enum PatternType {
  363. PT_CONSTANT,
  364. PT_BIND,
  365. PT_DICTIONARY,
  366. PT_ARRAY,
  367. PT_IGNORE_REST,
  368. PT_WILDCARD
  369. };
  370. PatternType pt_type;
  371. Node *constant;
  372. StringName bind;
  373. Map<ConstantNode *, PatternNode *> dictionary;
  374. Vector<PatternNode *> array;
  375. };
  376. struct PatternBranchNode : public Node {
  377. Vector<PatternNode *> patterns;
  378. BlockNode *body;
  379. };
  380. struct MatchNode : public Node {
  381. Node *val_to_match;
  382. Vector<PatternBranchNode *> branches;
  383. struct CompiledPatternBranch {
  384. Node *compiled_pattern;
  385. BlockNode *body;
  386. };
  387. Vector<CompiledPatternBranch> compiled_pattern_branches;
  388. };
  389. struct ControlFlowNode : public Node {
  390. enum CFType {
  391. CF_IF,
  392. CF_FOR,
  393. CF_WHILE,
  394. CF_BREAK,
  395. CF_CONTINUE,
  396. CF_RETURN,
  397. CF_MATCH
  398. };
  399. CFType cf_type;
  400. Vector<Node *> arguments;
  401. BlockNode *body;
  402. BlockNode *body_else;
  403. MatchNode *match;
  404. ControlFlowNode *_else; //used for if
  405. ControlFlowNode() {
  406. type = TYPE_CONTROL_FLOW;
  407. cf_type = CF_IF;
  408. body = nullptr;
  409. body_else = nullptr;
  410. }
  411. };
  412. struct CastNode : public Node {
  413. Node *source_node;
  414. DataType cast_type;
  415. DataType return_type;
  416. virtual DataType get_datatype() const { return return_type; }
  417. virtual void set_datatype(const DataType &p_datatype) { return_type = p_datatype; }
  418. CastNode() { type = TYPE_CAST; }
  419. };
  420. struct AssertNode : public Node {
  421. Node *condition;
  422. Node *message;
  423. AssertNode() :
  424. condition(0),
  425. message(0) {
  426. type = TYPE_ASSERT;
  427. }
  428. };
  429. struct BreakpointNode : public Node {
  430. BreakpointNode() { type = TYPE_BREAKPOINT; }
  431. };
  432. struct NewLineNode : public Node {
  433. NewLineNode() { type = TYPE_NEWLINE; }
  434. };
  435. struct Expression {
  436. bool is_op;
  437. union {
  438. OperatorNode::Operator op;
  439. Node *node;
  440. };
  441. };
  442. enum CompletionType {
  443. COMPLETION_NONE,
  444. COMPLETION_BUILT_IN_TYPE_CONSTANT,
  445. COMPLETION_GET_NODE,
  446. COMPLETION_FUNCTION,
  447. COMPLETION_IDENTIFIER,
  448. COMPLETION_PARENT_FUNCTION,
  449. COMPLETION_METHOD,
  450. COMPLETION_CALL_ARGUMENTS,
  451. COMPLETION_RESOURCE_PATH,
  452. COMPLETION_INDEX,
  453. COMPLETION_VIRTUAL_FUNC,
  454. COMPLETION_YIELD,
  455. COMPLETION_ASSIGN,
  456. COMPLETION_TYPE_HINT,
  457. COMPLETION_TYPE_HINT_INDEX,
  458. };
  459. private:
  460. GDScriptTokenizer *tokenizer;
  461. Node *head;
  462. Node *list;
  463. template <class T>
  464. T *alloc_node();
  465. bool validating;
  466. bool for_completion;
  467. int parenthesis;
  468. bool error_set;
  469. String error;
  470. int error_line;
  471. int error_column;
  472. bool check_types;
  473. bool dependencies_only;
  474. List<String> dependencies;
  475. #ifdef DEBUG_ENABLED
  476. Set<int> *safe_lines;
  477. #endif // DEBUG_ENABLED
  478. #ifdef DEBUG_ENABLED
  479. List<GDScriptWarning> warnings;
  480. #endif // DEBUG_ENABLED
  481. int pending_newline;
  482. struct IndentLevel {
  483. int indent;
  484. int tabs;
  485. bool is_mixed(IndentLevel other) {
  486. return (
  487. (indent == other.indent && tabs != other.tabs) ||
  488. (indent > other.indent && tabs < other.tabs) ||
  489. (indent < other.indent && tabs > other.tabs));
  490. }
  491. IndentLevel() :
  492. indent(0),
  493. tabs(0) {}
  494. IndentLevel(int p_indent, int p_tabs) :
  495. indent(p_indent),
  496. tabs(p_tabs) {}
  497. };
  498. List<IndentLevel> indent_level;
  499. String base_path;
  500. String self_path;
  501. ClassNode *current_class;
  502. FunctionNode *current_function;
  503. BlockNode *current_block;
  504. bool _get_completable_identifier(CompletionType p_type, StringName &identifier);
  505. void _make_completable_call(int p_arg);
  506. CompletionType completion_type;
  507. StringName completion_cursor;
  508. Variant::Type completion_built_in_constant;
  509. Node *completion_node;
  510. ClassNode *completion_class;
  511. FunctionNode *completion_function;
  512. BlockNode *completion_block;
  513. int completion_line;
  514. int completion_argument;
  515. bool completion_found;
  516. bool completion_ident_is_call;
  517. PropertyInfo current_export;
  518. MultiplayerAPI::RPCMode rpc_mode;
  519. void _set_error(const String &p_error, int p_line = -1, int p_column = -1);
  520. #ifdef DEBUG_ENABLED
  521. void _add_warning(int p_code, int p_line = -1, const String &p_symbol1 = String(), const String &p_symbol2 = String(), const String &p_symbol3 = String(), const String &p_symbol4 = String());
  522. void _add_warning(int p_code, int p_line, const Vector<String> &p_symbols);
  523. #endif // DEBUG_ENABLED
  524. bool _recover_from_completion();
  525. bool _parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete = false, bool p_parsing_constant = false);
  526. bool _enter_indent_block(BlockNode *p_block = nullptr);
  527. bool _parse_newline();
  528. Node *_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign = false, bool p_parsing_constant = false);
  529. Node *_reduce_expression(Node *p_node, bool p_to_const = false);
  530. Node *_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const = false, bool p_allow_assign = false);
  531. bool _reduce_export_var_type(Variant &p_value, int p_line = 0);
  532. PatternNode *_parse_pattern(bool p_static);
  533. void _parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode *> &p_branches, bool p_static);
  534. void _transform_match_statment(MatchNode *p_match_statement);
  535. void _generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node *> &p_bindings);
  536. void _parse_block(BlockNode *p_block, bool p_static);
  537. void _parse_extends(ClassNode *p_class);
  538. void _parse_class(ClassNode *p_class);
  539. bool _end_statement();
  540. void _set_end_statement_error(String p_name);
  541. void _determine_inheritance(ClassNode *p_class, bool p_recursive = true);
  542. bool _parse_type(DataType &r_type, bool p_can_be_void = false);
  543. DataType _resolve_type(const DataType &p_source, int p_line);
  544. DataType _type_from_variant(const Variant &p_value) const;
  545. DataType _type_from_property(const PropertyInfo &p_property, bool p_nil_is_variant = true) const;
  546. DataType _type_from_gdtype(const GDScriptDataType &p_gdtype) const;
  547. DataType _get_operation_type(const Variant::Operator p_op, const DataType &p_a, const DataType &p_b, bool &r_valid) const;
  548. Variant::Operator _get_variant_operation(const OperatorNode::Operator &p_op) const;
  549. bool _get_function_signature(DataType &p_base_type, const StringName &p_function, DataType &r_return_type, List<DataType> &r_arg_types, int &r_default_arg_count, bool &r_static, bool &r_vararg) const;
  550. bool _get_member_type(const DataType &p_base_type, const StringName &p_member, DataType &r_member_type) const;
  551. bool _is_type_compatible(const DataType &p_container, const DataType &p_expression, bool p_allow_implicit_conversion = false) const;
  552. Node *_get_default_value_for_type(const DataType &p_type, int p_line = -1);
  553. DataType _reduce_node_type(Node *p_node);
  554. DataType _reduce_function_call_type(const OperatorNode *p_call);
  555. DataType _reduce_identifier_type(const DataType *p_base_type, const StringName &p_identifier, int p_line, bool p_is_indexing);
  556. void _check_class_level_types(ClassNode *p_class);
  557. void _check_class_blocks_types(ClassNode *p_class);
  558. void _check_function_types(FunctionNode *p_function);
  559. void _check_block_types(BlockNode *p_block);
  560. _FORCE_INLINE_ void _mark_line_as_safe(int p_line) const {
  561. #ifdef DEBUG_ENABLED
  562. if (safe_lines)
  563. safe_lines->insert(p_line);
  564. #endif // DEBUG_ENABLED
  565. }
  566. _FORCE_INLINE_ void _mark_line_as_unsafe(int p_line) const {
  567. #ifdef DEBUG_ENABLED
  568. if (safe_lines)
  569. safe_lines->erase(p_line);
  570. #endif // DEBUG_ENABLED
  571. }
  572. Error _parse(const String &p_base_path);
  573. public:
  574. bool has_error() const;
  575. String get_error() const;
  576. int get_error_line() const;
  577. int get_error_column() const;
  578. #ifdef DEBUG_ENABLED
  579. const List<GDScriptWarning> &get_warnings() const { return warnings; }
  580. #endif // DEBUG_ENABLED
  581. Error parse(const String &p_code, const String &p_base_path = "", bool p_just_validate = false, const String &p_self_path = "", bool p_for_completion = false, Set<int> *r_safe_lines = nullptr, bool p_dependencies_only = false);
  582. Error parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path = "", const String &p_self_path = "");
  583. bool is_tool_script() const;
  584. const Node *get_parse_tree() const;
  585. //completion info
  586. CompletionType get_completion_type();
  587. StringName get_completion_cursor();
  588. int get_completion_line();
  589. Variant::Type get_completion_built_in_constant();
  590. Node *get_completion_node();
  591. ClassNode *get_completion_class();
  592. BlockNode *get_completion_block();
  593. FunctionNode *get_completion_function();
  594. int get_completion_argument_index();
  595. bool get_completion_identifier_is_function();
  596. const List<String> &get_dependencies() const { return dependencies; }
  597. void clear();
  598. GDScriptParser();
  599. ~GDScriptParser();
  600. };
  601. #endif // GDSCRIPT_PARSER_H