Make GRCAN CANdo Valid YAML, Parsers Tolerate Markers - #533
Draft
coderask wants to merge 1 commit into
Draft
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Valid YAML CAN Source
Problem and Scope
Doc/GRCAN.CANdois the single source of truth for the CAN configuration and is intended to be YAML, but it does not parse as valid YAML. Free-textcomment: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:
comment:blocks to literal block scalars (comment: |-)unitsvalues 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:|-,>) aftercomment:commentvalues (unitsvalues 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
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.
perlcriticpasses atseverity = brutalon both edited parsers, and both passperl -c.Larger Impact
GRCAN.CANdocan 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.