aboutsummaryrefslogtreecommitdiff
path: root/modules/gdscript/gd_parser.h
diff options
context:
space:
mode:
authorRémi Verschelde2017-03-19 00:36:26 +0100
committerRémi Verschelde2017-03-19 00:36:26 +0100
commitf8db8a3faa30b71dca33ced38be16d3f93f43e8a (patch)
tree3b798318132cca7eccfbca5818ab55656a2896d7 /modules/gdscript/gd_parser.h
parent1d418afe863c9e553b69174ce63aef203c46d2f0 (diff)
downloadgodot-f8db8a3faa30b71dca33ced38be16d3f93f43e8a.tar.gz
godot-f8db8a3faa30b71dca33ced38be16d3f93f43e8a.tar.zst
godot-f8db8a3faa30b71dca33ced38be16d3f93f43e8a.zip
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 5dbf1809c6e3e905b94b8764e99491e608122261.
Diffstat (limited to 'modules/gdscript/gd_parser.h')
-rw-r--r--modules/gdscript/gd_parser.h125
1 files changed, 65 insertions, 60 deletions
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h
index 8173cc348..9ee7c531f 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gd_parser.h
@@ -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();