mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-23 04:50:17 +00:00
up
This commit is contained in:
parent
c7157443aa
commit
5e1226b9ac
@ -98,29 +98,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Str eatStringUntil(char quote, bool raw) {
|
_Str eatStringUntil(char quote, bool raw) {
|
||||||
bool quote3 = false;
|
bool quote3 = parser->match_n_chars(2, quote);
|
||||||
std::string_view sv = parser->lookahead(2);
|
|
||||||
if(sv.size() == 2 && sv[0] == quote && sv[1] == quote) {
|
|
||||||
quote3 = true;
|
|
||||||
parser->eatchar();
|
|
||||||
parser->eatchar();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<char> buff;
|
std::vector<char> buff;
|
||||||
while (true) {
|
while (true) {
|
||||||
char c = parser->eatchar_include_newLine();
|
char c = parser->eatchar_include_newLine();
|
||||||
if (c == quote){
|
if (c == quote){
|
||||||
if(quote3){
|
if(!quote3) break;
|
||||||
sv = parser->lookahead(2);
|
if(parser->match_n_chars(2, quote)) {
|
||||||
if(sv.size() == 2 && sv[0] == quote && sv[1] == quote) {
|
|
||||||
parser->eatchar();
|
|
||||||
parser->eatchar();
|
|
||||||
break;
|
break;
|
||||||
}
|
}else{
|
||||||
buff.push_back(c);
|
buff.push_back(c);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c == '\0'){
|
if (c == '\0'){
|
||||||
|
@ -117,13 +117,15 @@ struct Parser {
|
|||||||
|
|
||||||
inline char peekchar() const{ return *curr_char; }
|
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;
|
const char* c = curr_char;
|
||||||
for(int i=0; i<n; i++){
|
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++;
|
c++;
|
||||||
}
|
}
|
||||||
return std::string_view(curr_char, n);
|
for(int i=0; i<n; i++) eatchar_include_newLine();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int eat_spaces(){
|
int eat_spaces(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user