Skip to content

Make GRCAN CANdo Valid YAML, Parsers Tolerate Markers - #533

Draft
coderask wants to merge 1 commit into
mainfrom
perl-to-rust-parser-rewrite
Draft

Make GRCAN CANdo Valid YAML, Parsers Tolerate Markers#533
coderask wants to merge 1 commit into
mainfrom
perl-to-rust-parser-rewrite

Conversation

@coderask

Copy link
Copy Markdown
Contributor

Valid YAML CAN Source

Problem and Scope

Doc/GRCAN.CANdo is the single source of truth for the CAN configuration and is intended to be YAML, but it does not parse as valid YAML. Free-text comment: blocks and a handful of bare scalar values (units: %, comments containing : or opening with [) are misread as structure. This prevents parsing the file with any standard YAML library and is the first step toward replacing the hand-rolled Perl parsers.

Description

Make the file valid YAML with the minimal edits that preserve every value:

  • Convert the 48 free-text comment: blocks to literal block scalars (comment: |-)
  • Quote the 12 inline comments and 10 units values that YAML cannot parse bare (units: '%', matching the single-quote convention already present in the file)

Teach the two parsers that consume these fields (STRUCTparser.pl, DBCparser.pl) to tolerate the new markers, keeping the existing manual line-based parsing:

  • Accept an optional block-scalar indicator (|-, >) after comment:
  • Strip surrounding quotes from inline comment values (units values already have quotes stripped at emit time)

Gotchas and Limitations

The committed generated headers and DBC files were already stale (and CRLF) before this change, so they are intentionally left untouched here. Regenerating and committing the outputs is a separate change.

Testing

  • HOOTL testing
  • HITL testing
  • Human tested

Testing Details

Regenerated all eight artifacts from both the pre-change and post-change sources; the output is byte-identical, so the change is behavior-preserving. perlcritic passes at severity = brutal on both edited parsers, and both pass perl -c.

Larger Impact

GRCAN.CANdo can now be read by a standard YAML library, unblocking a typed rewrite of the CAN code-generation parsers.

Additional Context and Ticket

Groundwork for migrating the CAN Perl parsers off hand-rolled parsing.

Convert the free-text comment blocks in GRCAN.CANdo to literal block
scalars and quote the scalar values YAML cannot parse bare, so the file
parses as valid YAML with no change to any value.

Teach STRUCTparser.pl and DBCparser.pl to tolerate the new markers while
keeping the existing manual parsing: accept an optional block-scalar
indicator after comment:, and strip surrounding quotes from inline
comment values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant