Closes #33
This commit is contained in:
1 parent
f60faea2e7
commit
f03882d3f4
86 files changed
+3539
-2688
No files matched your search
+14
-10
@@ -537,12 +537,12 @@ Structured diagnostics</h2>
|
||||
<div class="line"> <span class="keyword">const</span> <a class="code hl_class" href="classDecodeDatabase.html">DecodeDatabase</a> runtime = <a class="code hl_class" href="classDbcDecodeBuilder.html">DbcDecodeBuilder</a>().<a class="code hl_function" href="classDbcDecodeBuilder.html#a2bc6386dfb5e58976c42e22c19ec471b">Build</a>(result.<a class="code hl_variable" href="structDbcParseResult.html#abfa765d29a4397e8ddaf771bae21993e">database</a>);</div>
|
||||
<div class="line"> <span class="comment">// Inspect warnings before relying on decoding results.</span></div>
|
||||
<div class="line">}</div>
|
||||
<div class="ttc" id="aclassDbcParser_html"><div class="ttname"><a href="classDbcParser.html">DbcParser</a></div><div class="ttdoc">Minimal DBC parser.</div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8h_source.html#l00043">dbc_parser.h:43</a></div></div>
|
||||
<div class="ttc" id="aclassDbcParser_html_a0e915ce79c2e3d4c95a5aaf2bf0409bc"><div class="ttname"><a href="classDbcParser.html#a0e915ce79c2e3d4c95a5aaf2bf0409bc">DbcParser::ParseFileWithDiagnostics</a></div><div class="ttdeci">DbcParseResult ParseFileWithDiagnostics(const std::string &filePath) const</div><div class="ttdoc">Parse with warnings and a structured first error instead of throwing.</div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8cpp_source.html#l00103">dbc_parser.cpp:103</a></div></div>
|
||||
<div class="ttc" id="astructDbcDiagnostic_html"><div class="ttname"><a href="structDbcDiagnostic.html">DbcDiagnostic</a></div><div class="ttdoc">Diagnostic message and physical source location.</div><div class="ttdef"><b>Definition</b> <a href="dbc__diagnostic_8h_source.html#l00029">dbc_diagnostic.h:29</a></div></div>
|
||||
<div class="ttc" id="astructDbcParseResult_html"><div class="ttname"><a href="structDbcParseResult.html">DbcParseResult</a></div><div class="ttdoc">Parsed database and diagnostics; the database is empty on error.</div><div class="ttdef"><b>Definition</b> <a href="dbc__diagnostic_8h_source.html#l00038">dbc_diagnostic.h:38</a></div></div>
|
||||
<div class="ttc" id="astructDbcParseResult_html_a4da8641de3f6b55c7447c4421e05d20d"><div class="ttname"><a href="structDbcParseResult.html#a4da8641de3f6b55c7447c4421e05d20d">DbcParseResult::HasErrors</a></div><div class="ttdeci">bool HasErrors() const</div><div class="ttdoc">Return whether any diagnostic has error severity.</div><div class="ttdef"><b>Definition</b> <a href="dbc__diagnostic_8h_source.html#l00043">dbc_diagnostic.h:43</a></div></div>
|
||||
<div class="ttc" id="astructDbcParseResult_html_abfa765d29a4397e8ddaf771bae21993e"><div class="ttname"><a href="structDbcParseResult.html#abfa765d29a4397e8ddaf771bae21993e">DbcParseResult::database</a></div><div class="ttdeci">DbcDatabase database</div><div class="ttdef"><b>Definition</b> <a href="dbc__diagnostic_8h_source.html#l00039">dbc_diagnostic.h:39</a></div></div>
|
||||
<div class="ttc" id="aclassDbcParser_html"><div class="ttname"><a href="classDbcParser.html">DbcParser</a></div><div class="ttdoc">Minimal DBC parser.</div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8h_source.html#l00045">dbc_parser.h:45</a></div></div>
|
||||
<div class="ttc" id="aclassDbcParser_html_a0e915ce79c2e3d4c95a5aaf2bf0409bc"><div class="ttname"><a href="classDbcParser.html#a0e915ce79c2e3d4c95a5aaf2bf0409bc">DbcParser::ParseFileWithDiagnostics</a></div><div class="ttdeci">DbcParseResult ParseFileWithDiagnostics(const std::string &filePath) const</div><div class="ttdoc">Parse with warnings and a structured first error instead of throwing.</div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8cpp_source.html#l00105">dbc_parser.cpp:105</a></div></div>
|
||||
<div class="ttc" id="astructDbcDiagnostic_html"><div class="ttname"><a href="structDbcDiagnostic.html">DbcDiagnostic</a></div><div class="ttdoc">Diagnostic message and physical source location.</div><div class="ttdef"><b>Definition</b> <a href="dbc__diagnostic_8h_source.html#l00030">dbc_diagnostic.h:30</a></div></div>
|
||||
<div class="ttc" id="astructDbcParseResult_html"><div class="ttname"><a href="structDbcParseResult.html">DbcParseResult</a></div><div class="ttdoc">Parsed database and diagnostics; the database is empty on error.</div><div class="ttdef"><b>Definition</b> <a href="dbc__diagnostic_8h_source.html#l00039">dbc_diagnostic.h:39</a></div></div>
|
||||
<div class="ttc" id="astructDbcParseResult_html_a4da8641de3f6b55c7447c4421e05d20d"><div class="ttname"><a href="structDbcParseResult.html#a4da8641de3f6b55c7447c4421e05d20d">DbcParseResult::HasErrors</a></div><div class="ttdeci">bool HasErrors() const</div><div class="ttdoc">Return whether any diagnostic has error severity.</div><div class="ttdef"><b>Definition</b> <a href="dbc__diagnostic_8h_source.html#l00044">dbc_diagnostic.h:44</a></div></div>
|
||||
<div class="ttc" id="astructDbcParseResult_html_abfa765d29a4397e8ddaf771bae21993e"><div class="ttname"><a href="structDbcParseResult.html#abfa765d29a4397e8ddaf771bae21993e">DbcParseResult::database</a></div><div class="ttdeci">DbcDatabase database</div><div class="ttdef"><b>Definition</b> <a href="dbc__diagnostic_8h_source.html#l00040">dbc_diagnostic.h:40</a></div></div>
|
||||
</div><!-- fragment --><table class="markdownTable">
|
||||
<tr class="markdownTableHead">
|
||||
<th class="markdownTableHeadNone">Severity / code </th><th class="markdownTableHeadNone">Meaning </th></tr>
|
||||
@@ -559,10 +559,13 @@ Structured diagnostics</h2>
|
||||
<tr class="markdownTableRowEven">
|
||||
<td class="markdownTableBodyNone"><code>Warning</code> / <code>UnsupportedStatement</code> </td><td class="markdownTableBodyNone">Unregistered statement skipped; decoding or metadata may be incomplete </td></tr>
|
||||
<tr class="markdownTableRowOdd">
|
||||
<td class="markdownTableBodyNone"><code>Error</code> / <code>UnsupportedSignalType</code> </td><td class="markdownTableBodyNone"><code>SIG_VALTYPE_</code> declaration rejected to prevent incorrect integer decoding </td></tr>
|
||||
<tr class="markdownTableRowEven">
|
||||
<td class="markdownTableBodyNone"><code>Error</code> / <code>InvalidMultiplexing</code> </td><td class="markdownTableBodyNone">Invalid <code>SG_MUL_VAL_</code> syntax, references, ranges, or cycles </td></tr>
|
||||
</table>
|
||||
<p>Parsing stops at the first error and returns an empty database, together with any preceding warnings and the error. Deferred comment, <code>VAL_</code>, and multiplexing errors retain their original source lines. Invalid signal markers use <code>InvalidStatement</code>. <code>HasErrors()</code> checks severity; warnings alone do not make a parse fail.</p>
|
||||
<p>Unknown statements are reported conservatively, including <code>SIG_VALTYPE_</code>, attribute relation forms (<code>BA_REL_</code>, <code>BA_DEF_REL_</code>), signal types/references, environment variables, named <code>VAL_TABLE_</code> tables, and vendor extensions. For example, ignoring <code>SIG_VALTYPE_</code> may decode a floating-point signal as an integer. The parser does not implement the warned features; consumers should review warnings.</p>
|
||||
<p>All <code>SIG_VALTYPE_</code> declarations are rejected with <code>Error / UnsupportedSignalType</code>. This includes float32 (type 1), float64 (type 2), type 0, unknown types, and malformed declarations: the operator itself is not implemented. <code>ParseFile()</code> throws a source-located error; <code>ParseFileWithDiagnostics()</code> returns an empty database with the error and any preceding warnings. There is no permissive mode. This prevents IEEE 754 payload bits from being interpreted as a valid integer signal. Integer signals defined with <code>SG_</code> without this operator are unchanged. A bare <code>SIG_VALTYPE_</code> symbol inside an <code>NS_</code> symbol list remains quiet header metadata, rather than a value-type declaration.</p>
|
||||
<p>Other unknown statements are reported conservatively, including attribute relation forms (<code>BA_REL_</code>, <code>BA_DEF_REL_</code>), signal types/references, environment variables, named <code>VAL_TABLE_</code> tables, and vendor extensions. The parser does not implement the warned features; consumers should review warnings.</p>
|
||||
<h2><a class="anchor" id="autotoc_md97"></a>
|
||||
Attributes and frame metadata</h2>
|
||||
<p><code>BA_DEF_</code>, <code>BA_DEF_DEF_</code>, and <code>BA_</code> support database, <code>BO_</code>, <code>SG_</code>, <code>BU_</code>, and <code>EV_</code> scopes with <code>INT</code>, <code>HEX</code>, <code>FLOAT</code>, <code>STRING</code>, and <code>ENUM</code> definitions. Integer/HEX values use decimal signed 64-bit numbers; floating values are finite and locale independent. ENUM assignments use zero-based indices; defaults accept an index or a quoted label. Strings support escaped quotes and backslashes. Statements end with <code>;</code> outside quoted text and may span physical lines, including ENUM lists, defaults, and assignments. Newlines inside quoted strings are preserved; semicolons inside them do not terminate the statement. Attribute errors and format warnings refer to the statement's first physical line.</p>
|
||||
@@ -700,7 +703,7 @@ J1939 Opt-in and PGN Lookup</h1>
|
||||
<div class="line">options.<a class="code hl_variable" href="structDbcParserOptions.html#ab31534f5c0853461b46cbb38149c33f9">enableJ1939</a> = <span class="keyword">true</span>;</div>
|
||||
<div class="line"><span class="keyword">const</span> <a class="code hl_struct" href="structDbcDatabase.html">DbcDatabase</a> parsed = <a class="code hl_class" href="classDbcParser.html">DbcParser</a>(options).<a class="code hl_function" href="classDbcParser.html#aef72826942c9095d653fafa435855e56">ParseFile</a>(<span class="stringliteral">"vehicle.dbc"</span>);</div>
|
||||
<div class="line"><span class="keyword">const</span> <a class="code hl_class" href="classDecodeDatabase.html">DecodeDatabase</a> runtime = <a class="code hl_class" href="classDbcDecodeBuilder.html">DbcDecodeBuilder</a>().<a class="code hl_function" href="classDbcDecodeBuilder.html#a2bc6386dfb5e58976c42e22c19ec471b">Build</a>(parsed);</div>
|
||||
<div class="ttc" id="aclassDbcParser_html_aef72826942c9095d653fafa435855e56"><div class="ttname"><a href="classDbcParser.html#aef72826942c9095d653fafa435855e56">DbcParser::ParseFile</a></div><div class="ttdeci">DbcDatabase ParseFile(const std::string &filePath) const</div><div class="ttdoc">Parse DBC file.</div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8cpp_source.html#l00090">dbc_parser.cpp:90</a></div></div>
|
||||
<div class="ttc" id="aclassDbcParser_html_aef72826942c9095d653fafa435855e56"><div class="ttname"><a href="classDbcParser.html#aef72826942c9095d653fafa435855e56">DbcParser::ParseFile</a></div><div class="ttdeci">DbcDatabase ParseFile(const std::string &filePath) const</div><div class="ttdoc">Parse DBC file.</div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8cpp_source.html#l00092">dbc_parser.cpp:92</a></div></div>
|
||||
<div class="ttc" id="astructDbcDatabase_html"><div class="ttname"><a href="structDbcDatabase.html">DbcDatabase</a></div><div class="ttdoc">Parsed DBC content stored in a simple internal form.</div><div class="ttdef"><b>Definition</b> <a href="dbc__database_8h_source.html#l00022">dbc_database.h:22</a></div></div>
|
||||
<div class="ttc" id="astructDbcParserOptions_html"><div class="ttname"><a href="structDbcParserOptions.html">DbcParserOptions</a></div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8h_source.html#l00020">dbc_parser.h:20</a></div></div>
|
||||
<div class="ttc" id="astructDbcParserOptions_html_ab31534f5c0853461b46cbb38149c33f9"><div class="ttname"><a href="structDbcParserOptions.html#ab31534f5c0853461b46cbb38149c33f9">DbcParserOptions::enableJ1939</a></div><div class="ttdeci">bool enableJ1939</div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8h_source.html#l00021">dbc_parser.h:21</a></div></div>
|
||||
@@ -864,7 +867,7 @@ Statement Handler Factory</h1>
|
||||
<div class="ttc" id="astructDbcParseContext_html"><div class="ttname"><a href="structDbcParseContext.html">DbcParseContext</a></div><div class="ttdef"><b>Definition</b> <a href="dbc__statement__handler_8h_source.html#l00060">dbc_statement_handler.h:60</a></div></div>
|
||||
</div><!-- fragment --><p>Register it in the dispatcher constructor:</p>
|
||||
<div class="fragment"><div class="line">RegisterType<MyCustomHandler>(<span class="stringliteral">"CUSTOM_"</span>); <span class="comment">// after implementing MyCustomHandler</span></div>
|
||||
</div><!-- fragment --><p>Registration creates one handler; replacing a registration replaces that instance. Register during initialization before dispatching. A line is routed using its full first whitespace-delimited keyword, so <code>BO_TX_BU_</code> cannot match <code>BO_</code>. Unregistered keywords produce <code>UnsupportedStatement</code> warnings through <code>ParseFileWithDiagnostics</code>. <code>SG_</code> and <code>CM_</code> accept spaces and tabs after their keywords.</p>
|
||||
</div><!-- fragment --><p>Registration creates one handler; replacing a registration replaces that instance. Register during initialization before dispatching. A line is routed using its full first whitespace-delimited keyword, so <code>BO_TX_BU_</code> cannot match <code>BO_</code>. Unregistered keywords produce <code>UnsupportedStatement</code> warnings through <code>ParseFileWithDiagnostics</code>. A registered rejection handler for <code>SIG_VALTYPE_</code> produces <code>UnsupportedSignalType</code> errors instead of skipping the declaration. <code>SG_</code> and <code>CM_</code> accept spaces and tabs after their keywords.</p>
|
||||
<p>This factory handles statements inside DBC files. A separate format-level factory can be introduced when another file format is implemented. The decoder and database builders remain independent of statement dispatch.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md136"></a>
|
||||
@@ -893,7 +896,7 @@ Current Limitations</h1>
|
||||
<li>multiple parent selectors for one signal</li>
|
||||
<li>named <code>VAL_TABLE_</code> tables and environment-variable value descriptions</li>
|
||||
<li>attribute relation forms (<code>BA_REL_</code>, <code>BA_DEF_REL_</code>)</li>
|
||||
<li><code>SIG_VALTYPE_</code> floating-point signal types</li>
|
||||
<li>explicit <code>SIG_VALTYPE_</code> signal value types (declarations are rejected with an error)</li>
|
||||
<li>signal types/references (<code>SGTYPE_</code>, <code>SIG_TYPE_REF_</code>) and environment variables</li>
|
||||
<li>advanced comment handling</li>
|
||||
<li>full DBC grammar coverage</li>
|
||||
@@ -1065,6 +1068,7 @@ Build and run the demo</h2>
|
||||
<div class="line">make -j</div>
|
||||
<div class="line">./dbc_demo /absolute/path/to/example.dbc</div>
|
||||
</div><!-- fragment --><p>The demo prints the parsed tree and decodes eight zero bytes using the first frame definition. Replace that sample payload in <code><a class="el" href="examples_2main_8cpp.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">examples/main.cpp</a></code> to feed live CAN data or trace records.</p>
|
||||
<p>The demo prints all parser diagnostics, including severity and source location, and exits with code 2 before building or decoding when parsing reports an error. Warnings remain visible when parsing succeeds.</p>
|
||||
<h2><a class="anchor" id="autotoc_md152"></a>
|
||||
Generate API documentation</h2>
|
||||
<p>With Doxygen installed, run from the repository root:</p>
|
||||
|
||||
Reference in new issue
Block a user