bit-dream / candied

A zero dependency DBC parser written in pure Javascript/Typescript
MIT License
33 stars 10 forks source link

Inline file comment support #20

Open bit-dream opened 1 year ago

bit-dream commented 1 year ago

DBC files have support for inline, C style commenting. This isn't called out in any of the Vector documentation, however tools like CANDb++ will not throw errors while parsing dbc files that contain such comments. Tooling typically doesn't display these comments like it would CM, CM SG_ fields, etc., but it would be nice to be able to preserve as much meta-data that we can so we can inject it back in when we write back content to a file.

Examples Here is a quick example of the type of comments I'm referring to

// This is a supported in-line file comment
BU_: Node2 Node1 Node0
VAL_TABLE_ Value0 2 "Value2" 1 "Value1" 0 "Value0" ; // I can have comments in-line with other DBC definitions too
VAL_TABLE_ Numbers 3 "Three" 2 "Two" 1 "One" 0 "Zero" ;

/* This is NOT a supported comment, comments have to start with '//' */
BO_ 2147487969 CANMultiplexed: 2 Node0
 SG_ Value1 m1 : 8|8@1+ (1,0) [0|0] ""  Node1
 SG_ Value0 m0 : 8|8@1+ (1,0) [0|0] ""  Node0
 SG_ Multiplexer M : 0|8@1+ (1,0) [0|0] ""  Node0

BO_ 1234 CANMessage: 8 Node0
 SG_ Signal1 : 32|32@1+ (100,0) [0|100] "%"  Node1,Node2
 SG_ Signal0 : 0|32@1- (1,0) [0|0] ""  Node1,Node2