Skip to content

Commit c5cb3af

Browse files
committed
Fix/Change: fixed parsing of floating point numbers + DBC's new symbols section is iidentified with NS_ and _NS
1 parent b205d06 commit c5cb3af

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

include/Tokenizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class Tokenizer {
3838
bool started;
3939

4040
protected:
41-
unsigned long long charCnt;
42-
unsigned long long lineCnt;
41+
size_t charCnt;
42+
size_t lineCnt;
4343
bool addLine;
4444
};
4545

src/parsing/DBCParser.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "DBCParser.h"
22
#include "CANDatabaseException.h"
33
#include <string>
4+
#include <sstream>
45
#include <iostream>
56
#include <algorithm>
67
#include <iterator>
@@ -10,7 +11,8 @@
1011
using namespace DBCParser;
1112

1213
static std::string VERSION_TOKEN = "VERSION";
13-
static std::string NS_SECTION_TOKEN = "NS_";
14+
static std::string NS_SECTION_TOKEN1 = "NS_";
15+
static std::string NS_SECTION_TOKEN2 = "_NS";
1416
static std::string BIT_TIMING_TOKEN = "BS_";
1517
static std::string NODE_DEF_TOKEN = "BU_";
1618
static std::string MESSAGE_DEF_TOKEN = "BO_";
@@ -32,8 +34,10 @@ static std::set<std::string> SUPPORTED_DBC_TOKENS = {
3234

3335
static std::set<std::string> NS_TOKENS = {
3436
"CM_", "BA_DEF_", "BA_", "VAL_", "CAT_DEF_", "CAT_", "FILTER", "BA_DEF_DEF_",
35-
"EV_DATA_", "ENVVAR_DATA", "SGTYPE_", "SGTYPE_VAL_", "BA_DEF_SGTYPE_", "BA_SGTYPE_",
36-
"SIG_TYPE_DEF_"
37+
"EV_DATA_", "ENVVAR_DATA_", "SGTYPE_", "SGTYPE_VAL_", "BA_DEF_SGTYPE_", "BA_SGTYPE_",
38+
"SIG_TYPE_DEF_", "SIG_TYPE_REF_", "VAL_TABLE_", "SIG_GROUP_", "SIG_VALTYPE_",
39+
"SIGTYPE_VALTYPE_", "BO_TX_BU_", "BA_DEF_REL_", "BA_REL_", "BA_DEF_DEF_REL_",
40+
"BU_SG_REL_", "BU_EV_REL_", "BU_BO_REL_"
3741
};
3842

3943
static std::set<std::string> UNSUPPORTED_DBC_TOKENS = {
@@ -63,7 +67,8 @@ std::string parseVersionSection(Tokenizer& tokenizer) {
6367

6468
static void
6569
parseNSSection(Tokenizer& tokenizer) {
66-
if(!peek_token(tokenizer, NS_SECTION_TOKEN))
70+
if(!peek_token(tokenizer, NS_SECTION_TOKEN1) &&
71+
!peek_token(tokenizer, NS_SECTION_TOKEN2)) // Sometimes, one can find both NS_ ans _NS in DBC files
6772
return;
6873

6974
assert_token(tokenizer, ":");

src/parsing/Tokenizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ std::string Tokenizer::parseNumber(bool& is_float) {
264264
else if(currentChar == '-') {
265265
result += currentChar;
266266
is_float = true;
267-
currentChar == getNextChar();
267+
currentChar = getNextChar();
268268
}
269269
}
270270
}

0 commit comments

Comments
 (0)