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:
22
parser.cpp
22
parser.cpp
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user