From b4969373b3475799d6b24cdffeda4659c37f0b8a Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 5 Apr 2014 18:50:09 -0300 Subject: =?UTF-8?q?-HttpClient:=20=E2=80=99Content-Length=E2=80=99=20is=20?= =?UTF-8?q?added=20to=20httprequest=20if=20not=20provided=20in=20the=20hea?= =?UTF-8?q?ders=20and=20a=20body=20exists=20-expressions=20in=20GDScript?= =?UTF-8?q?=20can=20take=20multiple=20lines=20if=20inside=20parenthesis=20?= =?UTF-8?q?(python-like)=20-Added=20\=20to=20force=20linebreaks=20to=20GDs?= =?UTF-8?q?cript=20(python-like)=20-added=20exclude=20objects=20from=20ray?= =?UTF-8?q?cast=20-fixed=20crashes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gdscript/gd_parser.cpp | 16 ++++++++++++++++ modules/gdscript/gd_parser.h | 1 + modules/gdscript/gd_tokenizer.cpp | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) (limited to 'modules/gdscript') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index f962f8c5fb..f540660cd3 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -174,10 +174,19 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ /* Parse Operand */ /*****************/ + if (parenthesis>0) { + //remove empty space (only allowed if inside parenthesis + while(tokenizer->get_token()==GDTokenizer::TK_NEWLINE) { + tokenizer->advance(); + } + } + if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_OPEN) { //subexpression () tokenizer->advance(); + parenthesis++; Node* subexpr = _parse_expression(p_parent,p_static); + parenthesis--; if (!subexpr) return NULL; @@ -629,6 +638,12 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ /* Parse Operator */ /******************/ + if (parenthesis>0) { + //remove empty space (only allowed if inside parenthesis + while(tokenizer->get_token()==GDTokenizer::TK_NEWLINE) { + tokenizer->advance(); + } + } Expression e; e.is_op=false; @@ -2475,6 +2490,7 @@ void GDParser::clear() { tab_level.push_back(0); error_line=0; error_column=0; + parenthesis=0; current_export.type=Variant::NIL; error=""; diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h index 1925808cac..278e5f543d 100644 --- a/modules/gdscript/gd_parser.h +++ b/modules/gdscript/gd_parser.h @@ -356,6 +356,7 @@ private: template T* alloc_node(); + int parenthesis; bool error_set; String error; int error_line; diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index ff9be7926b..aeee1f6667 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -242,6 +242,24 @@ void GDTokenizerText::_advance() { case 0: _make_token(TK_EOF); break; + case '\\': + INCPOS(1); + if (GETCHAR(0)=='\r') { + INCPOS(1); + } + + if (GETCHAR(0)!='\n') { + _make_error("Expected newline after '\\'."); + return; + } + + INCPOS(1); + + while(GETCHAR(0)==' ' || GETCHAR(0)=='\t') { + INCPOS(1); + } + + continue; case '\t': case '\r': case ' ': -- cgit v1.2.3