diff --git a/src/compiler.h b/src/compiler.h index 03ff2804..af78b483 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -98,29 +98,17 @@ 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(); 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) break; + if(parser->match_n_chars(2, quote)) { + break; + }else{ buff.push_back(c); continue; - } else { - break; } } if (c == '\0'){ diff --git a/src/parser.h b/src/parser.h index 223d0859..25768f03 100644 --- a/src/parser.h +++ b/src/parser.h @@ -117,13 +117,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