Repository navigation
pxf: keep a comment that no entry follows (#176) - #177
Merged
Merged
Conversation
Ports protowire-go#283 (Go's #279). The parser attached a pending
comment only to the entry after it, so a comment at the end of a
document was dropped, one before a block's '}' was dropped or carried
out of the block onto the next entry, and comments between dataset
rows went to the next directive or were dropped.
Document, Block and BlockVal gain trailing_comments, taken before the
closing token is consumed. DatasetRow gains leading_comments, the
comments before its '(' and inside it, taken by ParseTableRow itself.
DatasetReader now parses a row from the start of its buffer, as Go's
parseRow does, so the comments the scan skipped before the '(' are the
row's, as Parse files them; the comment-dropping row parser is gone.
FormatDocument writes the new comments in place, CanonicalizeKeyed
carries them through the blocks it builds and keeps the comments of a
key assignment it drops last in a block, and the Rewriter's clones copy
them.
The differential dumpers on both sides print the new fields. Against
protowire-go b3c210f the differential failed on ParseTolerant before
this and reports no differences after it.
Merged
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.
Fixes #176.
cpp now keeps a comment that no entry follows, as protowire-go does since protowire-go#283 (Go's #279). Without this, the differential against Go main fails on every PR, the release PR #175 included.
What changes for a reader of the AST
Document::trailing_comments. It was dropped.}goes to the newBlock::trailing_commentsorBlockVal::trailing_comments. It was dropped, or moved out of the block onto the next entry.(, and inside the row, go to the newDatasetRow::leading_comments. They went to the next directive, or were dropped.ParseandDatasetReaderset them the same way. The reader now parses a row from the start of its buffer, as Go'sparseRowdoes, and the parser mode that dropped those comments is gone.FormatDocumentwrites each where it was. A comment inside a row comes out before the row, since a row is written on one line.CanonicalizeKeyedkeeps the comments through the blocks it builds, and the Rewriter's copies keep them too.Evidence
scripts/go_differential.shwith spec dd8e221 and Go b3c210f: before this change,ParseTolerant differs(2 lines, both the# chordscomment intestdata/differential/rewrite/settings.pxf); after it,no differences. The dumpers on both sides (cmd/pxf_diff,tools/godiff) now print the new fields, and Go's output is one line longer than before, which is that comment.test/pxf_closing_comments_test.cc(4 tests) andKeyed.CanonicalizeKeepsClosingCommentsport Go'sformat_comments_test.gowith the same documents and expected output. All 5 fail with the parser, formatter, keyed and reader changes reverted, and pass with them.Not ported
Go's new
FuzzFormatDocumentFixedPointfuzzer is not ported: this repo has no fuzz targets at all (noLLVMFuzzerTestOneInputanywhere). Every new test does check the format → parse → format fixed point.Then
Once this merges, I'll rebase the release PR #175 so 2.1.0 includes it.