Allow for linebreaks in function calls and definitions and yeild/signal.
(Plus maybe a few other things)
This commit is contained in:
parent
78d97b060a
commit
16a0e4b235
1 changed files with 30 additions and 2 deletions
|
@ -121,6 +121,7 @@ bool GDParser::_parse_arguments(Node* p_parent,Vector<Node*>& p_args,bool p_stat
|
|||
tokenizer->advance();
|
||||
} else {
|
||||
|
||||
parenthesis ++;
|
||||
int argidx=0;
|
||||
|
||||
while(true) {
|
||||
|
@ -165,6 +166,7 @@ bool GDParser::_parse_arguments(Node* p_parent,Vector<Node*>& p_args,bool p_stat
|
|||
}
|
||||
|
||||
}
|
||||
parenthesis --;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -364,18 +366,23 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||
OperatorNode *yield = alloc_node<OperatorNode>();
|
||||
yield->op=OperatorNode::OP_YIELD;
|
||||
|
||||
while (tokenizer->get_token()==GDTokenizer::TK_NEWLINE) {
|
||||
tokenizer->advance();
|
||||
}
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE) {
|
||||
expr=yield;
|
||||
tokenizer->advance();
|
||||
} else {
|
||||
|
||||
parenthesis ++;
|
||||
|
||||
Node *object = _parse_and_reduce_expression(p_parent,p_static);
|
||||
if (!object)
|
||||
return NULL;
|
||||
yield->arguments.push_back(object);
|
||||
|
||||
if (tokenizer->get_token()!=GDTokenizer::TK_COMMA) {
|
||||
|
||||
_set_error("Expected ',' after first argument of 'yield'");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -403,11 +410,12 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
|||
yield->arguments.push_back(signal);
|
||||
|
||||
if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
|
||||
|
||||
_set_error("Expected ')' after second argument of 'yield'");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
parenthesis --;
|
||||
|
||||
tokenizer->advance();
|
||||
|
||||
expr=yield;
|
||||
|
@ -1705,6 +1713,7 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
|
|||
case GDTokenizer::TK_CF_IF: {
|
||||
|
||||
tokenizer->advance();
|
||||
|
||||
Node *condition = _parse_and_reduce_expression(p_block,p_static);
|
||||
if (!condition) {
|
||||
if (_recover_from_completion()) {
|
||||
|
@ -2305,6 +2314,11 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
|||
bool defaulting=false;
|
||||
while(true) {
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_NEWLINE) {
|
||||
tokenizer->advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_PR_VAR) {
|
||||
|
||||
tokenizer->advance(); //var before the identifier is allowed
|
||||
|
@ -2357,6 +2371,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
|||
default_values.push_back(on);
|
||||
}
|
||||
|
||||
while (tokenizer->get_token()==GDTokenizer::TK_NEWLINE) {
|
||||
tokenizer->advance();
|
||||
}
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_COMMA) {
|
||||
tokenizer->advance();
|
||||
continue;
|
||||
|
@ -2398,6 +2416,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
|||
|
||||
if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
|
||||
//has arguments
|
||||
parenthesis ++;
|
||||
while(true) {
|
||||
|
||||
Node *arg = _parse_and_reduce_expression(p_class,_static);
|
||||
|
@ -2415,6 +2434,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
|||
break;
|
||||
|
||||
}
|
||||
parenthesis --;
|
||||
}
|
||||
|
||||
tokenizer->advance();
|
||||
|
@ -2478,6 +2498,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
|||
if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_OPEN) {
|
||||
tokenizer->advance();
|
||||
while(true) {
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_NEWLINE) {
|
||||
tokenizer->advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE) {
|
||||
|
@ -2493,6 +2517,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
|||
sig.arguments.push_back(tokenizer->get_token_identifier());
|
||||
tokenizer->advance();
|
||||
|
||||
while (tokenizer->get_token()==GDTokenizer::TK_NEWLINE) {
|
||||
tokenizer->advance();
|
||||
}
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_COMMA) {
|
||||
tokenizer->advance();
|
||||
} else if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
|
||||
|
|
Loading…
Reference in a new issue