16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 23:19:19 +02:00

support escape sequence \ in parser

This commit is contained in:
milek7
2019-10-12 19:31:59 +02:00
parent f6ce47f212
commit b9791a6699

View File

@@ -267,13 +267,27 @@ std::string cParser::readToken( bool ToLower, const char *Break ) {
std::string cParser::readQuotes(char const Quote) { // read the stream until specified char or stream end std::string cParser::readQuotes(char const Quote) { // read the stream until specified char or stream end
std::string token = ""; std::string token = "";
char c { 0 }; char c { 0 };
while( mStream->peek() != EOF && Quote != (c = mStream->get()) ) { // get all chars until the quote mark bool escaped = false;
if( c == '\n' ) { while( mStream->peek() != EOF ) { // get all chars until the quote mark
// update line counter c = mStream->get();
++mLine;
if (escaped) {
escaped = false;
} }
else {
if (c == '\\') {
escaped = true;
continue;
}
else if (c == Quote)
break;
}
if (c == '\n')
++mLine; // update line counter
token += c; token += c;
} }
return token; return token;
} }