void ScannerTestBase::scanAndExpectIdentifier(const char *expected_name) { ASSERT_EQ(IDENTIFIER, yylex()); ASSERT_TRUE(yylval); expectIdentifier(yylval->data.cstring_value, expected_name); free(yylval); }
bool DbcParser::parseSection(CanDb &candb, DbcTokenList &tokens) { bool retval = true; QString sectionName; QStringList strings; while (retval) { if (tokens.isEmpty()) { break; } if (expectIdentifier(tokens, §ionName, true, true)) { if (sectionName == "VERSION") { retval &= parseSectionVersion(candb, tokens); } else if (sectionName == "NS_") { strings.clear(); retval &= parseIdentifierList(tokens, &strings); } else if (sectionName == "BS_") { retval &= parseSectionBs(tokens); } else if (sectionName == "BU_") { retval &= parseSectionBu(candb, tokens); } else if (sectionName == "BO_") { retval &= parseSectionBo(candb, tokens); } else if (sectionName == "CM_") { retval &= parseSectionCm(candb, tokens); } else if (sectionName == "VAL_") { retval &= parseSectionVal(candb, tokens); } else { skipUntilSectionEnding(tokens); } } else { retval = false; } } if (!retval) { Backend::instance().logMessage(log_level_error, "dbc parse error"); } return retval; /* if (sectionName == "BA_") { return tokSectionBa; } if (sectionName == "BA_REL_") { return tokSectionBaRel; } if (sectionName == "BA_DEF_") { return tokSectionBaDef; } if (sectionName == "BA_DEF_DEF_") { return tokSectionBaDefDef; } if (sectionName == "BA_DEF_DEF_REL_") { return tokSectionBaDefDefRel; } */ }
bool DbcParser::parseIdentifierList(DbcTokenList &tokens, QStringList *list, bool newLineIsSectionEnding) { if (!expectAndSkipToken(tokens, dbc_tok_colon)) { return false; } QString id; while (expectIdentifier(tokens, &id, true, false, newLineIsSectionEnding)) { if (list) { list->append(id); } } return expectSectionEnding(tokens, newLineIsSectionEnding); }