Closes #25
This commit is contained in:
1 parent
c43222939f
commit
a258abf7be
7 files changed
+148
-5
No files matched your search
@@ -11,12 +11,16 @@ namespace {
|
||||
bool quoted = false;
|
||||
};
|
||||
|
||||
bool IsWhitespace(char character) {
|
||||
return character == ' ' || character == '\t' || character == '\n' || character == '\r';
|
||||
}
|
||||
|
||||
std::vector<Token> Tokenize(const std::string &text) {
|
||||
std::vector<Token> tokens;
|
||||
std::size_t index = 0U;
|
||||
while (index < text.size()) {
|
||||
const char character = text[index++];
|
||||
if (character == ' ' || character == '\t')
|
||||
if (IsWhitespace(character))
|
||||
continue;
|
||||
Token token;
|
||||
if (character == '"') {
|
||||
@@ -39,14 +43,14 @@ namespace {
|
||||
}
|
||||
if (!closed)
|
||||
throw std::runtime_error("Unterminated attribute string.");
|
||||
if (index < text.size() && text[index] != ' ' && text[index] != '\t' &&
|
||||
if (index < text.size() && !IsWhitespace(text[index]) &&
|
||||
text[index] != ',' && text[index] != ';')
|
||||
throw std::runtime_error("Missing separator after attribute string.");
|
||||
} else if (character == ';' || character == ',') {
|
||||
token.text = character;
|
||||
} else {
|
||||
token.text = character;
|
||||
while (index < text.size() && text[index] != ' ' && text[index] != '\t' &&
|
||||
while (index < text.size() && !IsWhitespace(text[index]) &&
|
||||
text[index] != ';' && text[index] != ',') {
|
||||
if (text[index] == '"')
|
||||
throw std::runtime_error("Missing separator before attribute string.");
|
||||
@@ -259,7 +263,7 @@ void DbcParseContext::ResolveAttributes(const std::string &filePath, std::vector
|
||||
const char *keywords[] = {"BA_DEF_", "BA_DEF_DEF_", "BA_"};
|
||||
for (const char *phase: keywords) {
|
||||
for (const PendingAttribute &pending: pendingAttributes) {
|
||||
const std::string keyword = pending.statement.substr(0U, pending.statement.find_first_of(" \t"));
|
||||
const std::string keyword = pending.statement.substr(0U, pending.statement.find_first_of(" \t\r\n"));
|
||||
if (keyword != phase) continue;
|
||||
try {
|
||||
AttributeTokens tokens(pending.statement);
|
||||
|
||||
Reference in new issue
Block a user