Refactor DBC parsing to use TypeFactory-based statement handlers #4

Closed
opened 2026-10-01 17:51:26 +00:00 by deeaitch · 0 comments
Owner

Scope:

  • Introduce a common statement-handler interface and a shared DBC parsing context.
  • Extract handlers for BO_, SG_, and CM_.
  • Register and instantiate handlers using TypeFactory, then reuse them throughout parsing.
  • Keep file reading, line tracking, and error reporting in DbcParser.
  • Preserve frame validation, parsed metadata, CAN ID normalization, and existing behavior for unsupported constructs.
  • Update README with the handler architecture and registration workflow.
  • Add tests for dispatch, handler reuse, and unrecognized keywords.
  • Do not modify generated docs.
    Design constraints:
  • Create handlers once per parser instance or parsing session, rather than once per line.
  • Keep mutable parsing state in the context so successive file parses remain independent.
  • Register full statement keywords; distinguish BO_ from BO_TX_BU_.
  • Introduce a separate format-level factory when a second format is implemented.
    Acceptance criteria:
  • BO_, SG_, and CM_ are dispatched through registered handlers.
  • Existing parser and decoder regression tests pass.
  • Parsing multiple files does not retain state from previous files.
  • Error messages retain file paths and line numbers.
  • README explains how to register an additional handler.
  • The project builds without warnings using -Wall -Wextra -Wpedantic -Werror.
Scope: - Introduce a common statement-handler interface and a shared DBC parsing context. - Extract handlers for BO_, SG_, and CM_. - Register and instantiate handlers using TypeFactory, then reuse them throughout parsing. - Keep file reading, line tracking, and error reporting in DbcParser. - Preserve frame validation, parsed metadata, CAN ID normalization, and existing behavior for unsupported constructs. - Update README with the handler architecture and registration workflow. - Add tests for dispatch, handler reuse, and unrecognized keywords. - Do not modify generated docs. Design constraints: - Create handlers once per parser instance or parsing session, rather than once per line. - Keep mutable parsing state in the context so successive file parses remain independent. - Register full statement keywords; distinguish BO_ from BO_TX_BU_. - Introduce a separate format-level factory when a second format is implemented. Acceptance criteria: - BO_, SG_, and CM_ are dispatched through registered handlers. - Existing parser and decoder regression tests pass. - Parsing multiple files does not retain state from previous files. - Error messages retain file paths and line numbers. - README explains how to register an additional handler. - The project builds without warnings using -Wall -Wextra -Wpedantic -Werror.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: automotive/dbc#4