grammar: Correctly parse double quotes as a means of escaping

This should parse the table and column names correctly by removing any
double quote characters and replacing them by a single one.

See issue #387.
This commit is contained in:
Martin Kleusberg
2015-08-18 22:54:16 +02:00
parent 631979c330
commit dce47b3404

View File

@@ -256,9 +256,20 @@ QString identifier(antlr::RefAST ident)
ident->getType() == Sqlite3Lexer::QUOTEDLITERAL ||
ident->getType() == sqlite3TokenTypes::STRINGLITERAL)
{
// Remember the way the identifier is quoted
QChar quoteChar = sident.at(0);
// Remove first and final character, i.e. the quotes
sident.remove(0, 1);
sident.remove(sident.length() - 1, 1);
sident.chop(1);
// Replace all remaining occurences of two succeeding quote characters and replace them
// by a single instance. This is done because two quotes can be used as a means of escaping
// the quote character, thus only the visual representation has its two quotes, the actual
// name contains only one.
sident.replace(QString(quoteChar) + quoteChar, quoteChar);
}
return sident;
}