You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Bring that Whole New World to the Old Continent too
Applies the clang-format style to the 2.1 branch as done for master in
5dbf1809c6.
This commit is contained in:
@@ -29,14 +29,13 @@
|
||||
#ifndef GD_PARSER_H
|
||||
#define GD_PARSER_H
|
||||
|
||||
#include "gd_tokenizer.h"
|
||||
#include "gd_functions.h"
|
||||
#include "gd_tokenizer.h"
|
||||
#include "map.h"
|
||||
#include "object.h"
|
||||
|
||||
class GDParser {
|
||||
public:
|
||||
|
||||
struct Node {
|
||||
|
||||
enum Type {
|
||||
@@ -58,7 +57,7 @@ public:
|
||||
TYPE_NEWLINE,
|
||||
};
|
||||
|
||||
Node * next;
|
||||
Node *next;
|
||||
int line;
|
||||
int column;
|
||||
Type type;
|
||||
@@ -77,7 +76,6 @@ public:
|
||||
StringName extends_file;
|
||||
Vector<StringName> extends_class;
|
||||
|
||||
|
||||
struct Member {
|
||||
PropertyInfo _export;
|
||||
#ifdef TOOLS_ENABLED
|
||||
@@ -99,11 +97,11 @@ public:
|
||||
Vector<StringName> arguments;
|
||||
};
|
||||
|
||||
Vector<ClassNode*> subclasses;
|
||||
Vector<ClassNode *> subclasses;
|
||||
Vector<Member> variables;
|
||||
Vector<Constant> constant_expressions;
|
||||
Vector<FunctionNode*> functions;
|
||||
Vector<FunctionNode*> static_functions;
|
||||
Vector<FunctionNode *> functions;
|
||||
Vector<FunctionNode *> static_functions;
|
||||
Vector<Signal> _signals;
|
||||
BlockNode *initializer;
|
||||
BlockNode *ready;
|
||||
@@ -111,73 +109,86 @@ public:
|
||||
//Vector<Node*> initializers;
|
||||
int end_line;
|
||||
|
||||
ClassNode() { tool=false; type=TYPE_CLASS; extends_used=false; end_line=-1; owner=NULL;}
|
||||
ClassNode() {
|
||||
tool = false;
|
||||
type = TYPE_CLASS;
|
||||
extends_used = false;
|
||||
end_line = -1;
|
||||
owner = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct FunctionNode : public Node {
|
||||
|
||||
bool _static;
|
||||
StringName name;
|
||||
Vector<StringName> arguments;
|
||||
Vector<Node*> default_values;
|
||||
Vector<Node *> default_values;
|
||||
BlockNode *body;
|
||||
|
||||
FunctionNode() { type=TYPE_FUNCTION; _static=false; }
|
||||
|
||||
FunctionNode() {
|
||||
type = TYPE_FUNCTION;
|
||||
_static = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct BlockNode : public Node {
|
||||
|
||||
ClassNode *parent_class;
|
||||
BlockNode *parent_block;
|
||||
Map<StringName,int> locals;
|
||||
List<Node*> statements;
|
||||
Map<StringName, int> locals;
|
||||
List<Node *> statements;
|
||||
Vector<StringName> variables;
|
||||
Vector<int> variable_lines;
|
||||
|
||||
//the following is useful for code completion
|
||||
List<BlockNode*> sub_blocks;
|
||||
List<BlockNode *> sub_blocks;
|
||||
int end_line;
|
||||
BlockNode() { type=TYPE_BLOCK; end_line=-1; parent_block=NULL; parent_class=NULL; }
|
||||
BlockNode() {
|
||||
type = TYPE_BLOCK;
|
||||
end_line = -1;
|
||||
parent_block = NULL;
|
||||
parent_class = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
struct TypeNode : public Node {
|
||||
|
||||
Variant::Type vtype;
|
||||
TypeNode() { type=TYPE_TYPE; }
|
||||
TypeNode() { type = TYPE_TYPE; }
|
||||
};
|
||||
struct BuiltInFunctionNode : public Node {
|
||||
GDFunctions::Function function;
|
||||
BuiltInFunctionNode() { type=TYPE_BUILT_IN_FUNCTION; }
|
||||
BuiltInFunctionNode() { type = TYPE_BUILT_IN_FUNCTION; }
|
||||
};
|
||||
|
||||
struct IdentifierNode : public Node {
|
||||
|
||||
StringName name;
|
||||
IdentifierNode() { type=TYPE_IDENTIFIER; }
|
||||
IdentifierNode() { type = TYPE_IDENTIFIER; }
|
||||
};
|
||||
|
||||
struct LocalVarNode : public Node {
|
||||
|
||||
StringName name;
|
||||
Node *assign;
|
||||
LocalVarNode() { type=TYPE_LOCAL_VAR; assign=NULL;}
|
||||
LocalVarNode() {
|
||||
type = TYPE_LOCAL_VAR;
|
||||
assign = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
struct ConstantNode : public Node {
|
||||
Variant value;
|
||||
ConstantNode() { type=TYPE_CONSTANT; }
|
||||
ConstantNode() { type = TYPE_CONSTANT; }
|
||||
};
|
||||
|
||||
struct ArrayNode : public Node {
|
||||
|
||||
Vector<Node*> elements;
|
||||
ArrayNode() { type=TYPE_ARRAY; }
|
||||
Vector<Node *> elements;
|
||||
ArrayNode() { type = TYPE_ARRAY; }
|
||||
};
|
||||
|
||||
|
||||
struct DictionaryNode : public Node {
|
||||
|
||||
struct Pair {
|
||||
@@ -187,11 +198,11 @@ public:
|
||||
};
|
||||
|
||||
Vector<Pair> elements;
|
||||
DictionaryNode() { type=TYPE_DICTIONARY; }
|
||||
DictionaryNode() { type = TYPE_DICTIONARY; }
|
||||
};
|
||||
|
||||
struct SelfNode : public Node {
|
||||
SelfNode() { type=TYPE_SELF; }
|
||||
SelfNode() { type = TYPE_SELF; }
|
||||
};
|
||||
|
||||
struct OperatorNode : public Node {
|
||||
@@ -251,8 +262,8 @@ public:
|
||||
|
||||
Operator op;
|
||||
|
||||
Vector<Node*> arguments;
|
||||
OperatorNode() { type=TYPE_OPERATOR; }
|
||||
Vector<Node *> arguments;
|
||||
OperatorNode() { type = TYPE_OPERATOR; }
|
||||
};
|
||||
|
||||
struct ControlFlowNode : public Node {
|
||||
@@ -267,28 +278,32 @@ public:
|
||||
};
|
||||
|
||||
CFType cf_type;
|
||||
Vector<Node*> arguments;
|
||||
Vector<Node *> arguments;
|
||||
BlockNode *body;
|
||||
BlockNode *body_else;
|
||||
|
||||
ControlFlowNode *_else; //used for if
|
||||
ControlFlowNode() { type=TYPE_CONTROL_FLOW; cf_type=CF_IF; body=NULL; body_else=NULL;}
|
||||
ControlFlowNode() {
|
||||
type = TYPE_CONTROL_FLOW;
|
||||
cf_type = CF_IF;
|
||||
body = NULL;
|
||||
body_else = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
struct AssertNode : public Node {
|
||||
Node* condition;
|
||||
AssertNode() { type=TYPE_ASSERT; }
|
||||
Node *condition;
|
||||
AssertNode() { type = TYPE_ASSERT; }
|
||||
};
|
||||
|
||||
struct BreakpointNode : public Node {
|
||||
BreakpointNode() { type=TYPE_BREAKPOINT; }
|
||||
BreakpointNode() { type = TYPE_BREAKPOINT; }
|
||||
};
|
||||
|
||||
struct NewLineNode : public Node {
|
||||
NewLineNode() { type=TYPE_NEWLINE; }
|
||||
NewLineNode() { type = TYPE_NEWLINE; }
|
||||
};
|
||||
|
||||
|
||||
struct Expression {
|
||||
|
||||
bool is_op;
|
||||
@@ -298,8 +313,7 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
struct OperatorNode : public Node {
|
||||
|
||||
DataType return_cache;
|
||||
@@ -381,18 +395,13 @@ public:
|
||||
COMPLETION_VIRTUAL_FUNC
|
||||
};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
GDTokenizer *tokenizer;
|
||||
|
||||
|
||||
Node *head;
|
||||
Node *list;
|
||||
template<class T>
|
||||
T* alloc_node();
|
||||
template <class T>
|
||||
T *alloc_node();
|
||||
|
||||
bool validating;
|
||||
bool for_completion;
|
||||
@@ -409,12 +418,11 @@ private:
|
||||
String base_path;
|
||||
String self_path;
|
||||
|
||||
|
||||
ClassNode *current_class;
|
||||
FunctionNode *current_function;
|
||||
BlockNode *current_block;
|
||||
|
||||
bool _get_completable_identifier(CompletionType p_type,StringName& identifier);
|
||||
bool _get_completable_identifier(CompletionType p_type, StringName &identifier);
|
||||
void _make_completable_call(int p_arg);
|
||||
|
||||
CompletionType completion_type;
|
||||
@@ -431,31 +439,29 @@ private:
|
||||
|
||||
PropertyInfo current_export;
|
||||
|
||||
void _set_error(const String& p_error, int p_line=-1, int p_column=-1);
|
||||
void _set_error(const String &p_error, int p_line = -1, int p_column = -1);
|
||||
bool _recover_from_completion();
|
||||
|
||||
|
||||
bool _parse_arguments(Node* p_parent, Vector<Node*>& p_args, bool p_static, bool p_can_codecomplete=false);
|
||||
bool _enter_indent_block(BlockNode *p_block=NULL);
|
||||
bool _parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete = false);
|
||||
bool _enter_indent_block(BlockNode *p_block = NULL);
|
||||
bool _parse_newline();
|
||||
Node* _parse_expression(Node *p_parent, bool p_static, bool p_allow_assign=false, bool p_parsing_constant=false);
|
||||
Node* _reduce_expression(Node *p_node,bool p_to_const=false);
|
||||
Node* _parse_and_reduce_expression(Node *p_parent,bool p_static,bool p_reduce_const=false,bool p_allow_assign=false);
|
||||
Node *_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign = false, bool p_parsing_constant = false);
|
||||
Node *_reduce_expression(Node *p_node, bool p_to_const = false);
|
||||
Node *_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const = false, bool p_allow_assign = false);
|
||||
|
||||
void _parse_block(BlockNode *p_block,bool p_static);
|
||||
void _parse_block(BlockNode *p_block, bool p_static);
|
||||
void _parse_extends(ClassNode *p_class);
|
||||
void _parse_class(ClassNode *p_class);
|
||||
bool _end_statement();
|
||||
|
||||
Error _parse(const String& p_base_path);
|
||||
Error _parse(const String &p_base_path);
|
||||
|
||||
public:
|
||||
|
||||
String get_error() const;
|
||||
int get_error_line() const;
|
||||
int get_error_column() const;
|
||||
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);
|
||||
Error parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p_base_path="",const String& p_self_path="");
|
||||
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);
|
||||
Error parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path = "", const String &p_self_path = "");
|
||||
|
||||
bool is_tool_script() const;
|
||||
const Node *get_parse_tree() const;
|
||||
@@ -472,7 +478,6 @@ public:
|
||||
FunctionNode *get_completion_function();
|
||||
int get_completion_argument_index();
|
||||
|
||||
|
||||
void clear();
|
||||
GDParser();
|
||||
~GDParser();
|
||||
|
||||
Reference in New Issue
Block a user