This commit is contained in:
blueloveTH 2023-01-31 21:11:55 +08:00
parent c7157443aa
commit 5e1226b9ac
2 changed files with 10 additions and 20 deletions

View File

@ -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<char> 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'){

View File

@ -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<n; i++){
if(*c == '\0') return std::string_view(curr_char, i);
if(*c == '\0') return false;
if(*c != c0) return false;
c++;
}
return std::string_view(curr_char, n);
for(int i=0; i<n; i++) eatchar_include_newLine();
return true;
}
int eat_spaces(){