|
8 | 8 |
|
9 | 9 | using namespace DBCParser; |
10 | 10 |
|
11 | | -CANSignal parseSignal(Tokenizer& tokenizer); |
12 | | -CANFrame parseFrame(Tokenizer& tokenizer); |
13 | | -std::set<std::string> parseECUs(Tokenizer& tokenizer); |
14 | | -void parseNewSymbols(Tokenizer& tokenizer); |
15 | | -void addBADirective(Tokenizer& tokenizer, |
16 | | - CANDatabase& db); |
17 | | -void addComment(Tokenizer& tokenizer, CANDatabase& db); |
18 | | -void parseSignalChoices(Tokenizer& tokenizer, |
19 | | - CANDatabase& db); |
20 | | - |
21 | 11 | static std::string VERSION_TOKEN = "VERSION"; |
22 | 12 | static std::string NS_SECTION_TOKEN = "NS_"; |
23 | 13 | static std::string BIT_TIMING_TOKEN = "BS_"; |
@@ -380,6 +370,16 @@ CANDatabase DBCParser::fromTokenizer(const std::string& name, Tokenizer& tokeniz |
380 | 370 | parseValDescSection(tokenizer, result); |
381 | 371 |
|
382 | 372 | while(!is_token(tokenizer, Token::Eof)) { |
| 373 | + // We have a syntax error because we have a token which does not |
| 374 | + // represent any command. |
| 375 | + if(!is_dbc_token(tokenizer.getCurrentToken())) { |
| 376 | + throw_error("Syntax error", |
| 377 | + "Unexpected token \"" + tokenizer.getCurrentToken().image + "\"", |
| 378 | + tokenizer.lineCount()); |
| 379 | + } |
| 380 | + |
| 381 | + // We have a valid DBC instruction, but we ignore it because |
| 382 | + // it is not in a valid position. |
383 | 383 | warning("Unexpected token " + tokenizer.getCurrentToken().image + |
384 | 384 | " at line " + std::to_string(tokenizer.lineCount()) + |
385 | 385 | " (maybe is it an unsupported instruction ? maybe is it a misplaced instruction ?)", |
|
0 commit comments