bumped simplecpp
This commit is contained in:
parent
1657439b18
commit
03c2c88d1e
|
@ -555,31 +555,44 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
|
|||
|
||||
// string / char literal
|
||||
else if (ch == '\"' || ch == '\'') {
|
||||
std::string prefix;
|
||||
if (cback() && cback()->name && !std::isspace(prevChar(istr, bom)) && (isStringLiteralPrefix(cback()->str()))) {
|
||||
prefix = cback()->str();
|
||||
}
|
||||
// C++11 raw string literal
|
||||
if (ch == '\"' && !prefix.empty() && *cback()->str().rbegin() == 'R') {
|
||||
std::string delim;
|
||||
currentToken = ch;
|
||||
bool hasR = *cback()->str().rbegin() == 'R';
|
||||
std::string prefix = cback()->str();
|
||||
if (hasR) {
|
||||
prefix.resize(prefix.size() - 1);
|
||||
delim = ")";
|
||||
ch = readChar(istr,bom);
|
||||
while (istr.good() && ch != '(' && ch != '\n') {
|
||||
delim += ch;
|
||||
ch = readChar(istr,bom);
|
||||
}
|
||||
if (!istr.good() || ch == '\n')
|
||||
// TODO report
|
||||
if (!istr.good() || ch == '\n') {
|
||||
if (outputList) {
|
||||
Output err(files);
|
||||
err.type = Output::SYNTAX_ERROR;
|
||||
err.location = location;
|
||||
err.msg = "Invalid newline in raw string delimiter.";
|
||||
outputList->push_back(err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const std::string endOfRawString(delim + currentToken);
|
||||
const std::string endOfRawString(')' + delim + currentToken);
|
||||
while (istr.good() && !(endsWith(currentToken, endOfRawString) && currentToken.size() > 1))
|
||||
currentToken += readChar(istr,bom);
|
||||
if (!endsWith(currentToken, endOfRawString))
|
||||
// TODO report
|
||||
if (!endsWith(currentToken, endOfRawString)) {
|
||||
if (outputList) {
|
||||
Output err(files);
|
||||
err.type = Output::SYNTAX_ERROR;
|
||||
err.location = location;
|
||||
err.msg = "Raw string missing terminating delimiter.";
|
||||
outputList->push_back(err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
currentToken.erase(currentToken.size() - endOfRawString.size(), endOfRawString.size() - 1U);
|
||||
if (hasR)
|
||||
currentToken = escapeString(currentToken);
|
||||
currentToken.insert(0, prefix);
|
||||
back()->setstr(currentToken);
|
||||
|
@ -588,12 +601,13 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
|
|||
location.col += 2 + 2 * delim.size();
|
||||
else
|
||||
location.col += 1 + delim.size();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
currentToken = readUntil(istr,location,ch,ch,outputList,bom);
|
||||
if (currentToken.size() < 2U)
|
||||
// TODO report
|
||||
// Error is reported by readUntil()
|
||||
return;
|
||||
|
||||
std::string s = currentToken;
|
||||
|
@ -604,7 +618,10 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
|
|||
newlines++;
|
||||
}
|
||||
|
||||
if (prefix.empty())
|
||||
push_back(new Token(s, location)); // push string without newlines
|
||||
else
|
||||
back()->setstr(prefix + s);
|
||||
|
||||
if (newlines > 0 && lastLine().compare(0,9,"# define ") == 0) {
|
||||
multiline += newlines;
|
||||
|
|
Loading…
Reference in New Issue