From c1485392cf260e6b30ed8866d776886234edd4ea Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Tue, 31 Jan 2023 21:17:25 +0800 Subject: [PATCH] up --- plugins/flutter/src/pocketpy.h | 40 ++++++++++++---------------------- plugins/godot/godot-cpp | 2 +- src/compiler.h | 12 +++++----- src/parser.h | 6 ++--- 4 files changed, 23 insertions(+), 37 deletions(-) diff --git a/plugins/flutter/src/pocketpy.h b/plugins/flutter/src/pocketpy.h index fb4e122d..5996c40d 100644 --- a/plugins/flutter/src/pocketpy.h +++ b/plugins/flutter/src/pocketpy.h @@ -3184,13 +3184,15 @@ struct Parser { inline char peekchar() const{ return *curr_char; } - std::string_view lookahead(int n) const{ + bool match_n_chars(int n, char c0){ const char* c = curr_char; for(int i=0; i__py2py_call_signal = new_object(_tp_object, (i64)7); + this->__py2py_call_signal = new_object(_tp_object, DUMMY_VAL); std::vector<_Str> publicTypes = {"type", "object", "bool", "int", "float", "str", "list", "tuple", "range"}; for (auto& name : publicTypes) { @@ -4968,30 +4970,16 @@ public: } _Str eatStringUntil(char quote, bool raw) { - bool quote3 = false; - std::string_view sv = parser->lookahead(2); - if(sv.size() == 2 && sv[0] == quote && sv[1] == quote) { - quote3 = true; - parser->eatchar(); - parser->eatchar(); - } - + bool quote3 = parser->match_n_chars(2, quote); std::vector buff; while (true) { - char c = parser->eatchar_include_newLine(); + char c = parser->eatchar_include_newline(); if (c == quote){ - if(quote3){ - sv = parser->lookahead(2); - if(sv.size() == 2 && sv[0] == quote && sv[1] == quote) { - parser->eatchar(); - parser->eatchar(); - break; - } + if(quote3 && !parser->match_n_chars(2, quote)){ buff.push_back(c); continue; - } else { - break; } + break; } if (c == '\0'){ if(quote3 && parser->src->mode == SINGLE_MODE){ @@ -5007,7 +4995,7 @@ public: } } if (!raw && c == '\\') { - switch (parser->eatchar_include_newLine()) { + switch (parser->eatchar_include_newline()) { case '"': buff.push_back('"'); break; case '\'': buff.push_back('\''); break; case '\\': buff.push_back('\\'); break; @@ -5076,7 +5064,7 @@ public: while (parser->peekchar() != '\0') { parser->token_start = parser->curr_char; - char c = parser->eatchar_include_newLine(); + char c = parser->eatchar_include_newline(); switch (c) { case '\'': case '"': eatString(c, NORMAL_STRING); return; case '#': parser->skip_line_comment(); break; diff --git a/plugins/godot/godot-cpp b/plugins/godot/godot-cpp index 67715ff0..e84dedd3 160000 --- a/plugins/godot/godot-cpp +++ b/plugins/godot/godot-cpp @@ -1 +1 @@ -Subproject commit 67715ff019df22dc7a99a73352515eb7106b33b9 +Subproject commit e84dedd36affa57df6b9bf845b456df2de5de872 diff --git a/src/compiler.h b/src/compiler.h index af78b483..a52971eb 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -101,15 +101,13 @@ public: bool quote3 = parser->match_n_chars(2, quote); std::vector buff; while (true) { - char c = parser->eatchar_include_newLine(); + char c = parser->eatchar_include_newline(); if (c == quote){ - if(!quote3) break; - if(parser->match_n_chars(2, quote)) { - break; - }else{ + if(quote3 && !parser->match_n_chars(2, quote)){ buff.push_back(c); continue; } + break; } if (c == '\0'){ if(quote3 && parser->src->mode == SINGLE_MODE){ @@ -125,7 +123,7 @@ public: } } if (!raw && c == '\\') { - switch (parser->eatchar_include_newLine()) { + switch (parser->eatchar_include_newline()) { case '"': buff.push_back('"'); break; case '\'': buff.push_back('\''); break; case '\\': buff.push_back('\\'); break; @@ -194,7 +192,7 @@ public: while (parser->peekchar() != '\0') { parser->token_start = parser->curr_char; - char c = parser->eatchar_include_newLine(); + char c = parser->eatchar_include_newline(); switch (c) { case '\'': case '"': eatString(c, NORMAL_STRING); return; case '#': parser->skip_line_comment(); break; diff --git a/src/parser.h b/src/parser.h index 25768f03..ccfc2019 100644 --- a/src/parser.h +++ b/src/parser.h @@ -124,7 +124,7 @@ struct Parser { if(*c != c0) return false; c++; } - for(int i=0; i