pxf: Result::Directives() / Result::Tables() accessors#12
Merged
Conversation
Third PR of the v0.72-v0.75 cpp catch-up. The fast-path direct
decoder previously walked directives just enough to satisfy the
standalone constraint and arity checks; it discarded their content.
This PR wires the parsed shape onto Result so consumers can read the
document-root directive list after UnmarshalFull returns.
API additions on Result:
- Directives() → const vector<Directive>& : generic
`@<name> *(prefix) [{ ... }]` blocks in source order. body holds
raw bytes between '{' and '}', preserved verbatim for downstream
re-parsing (chameleon's @Header reader, etc.). Single-prefix
populates the back-compat `type` field per v0.72.0 shape.
- Tables() → const vector<TableDirective>& : @table directives
with full column metadata and parsed cell ValuePtr per row,
faithful to the three-state cell grammar (absent / present-null /
present-with-value).
- AddDirective(...) / AddTable(...) : internal mutators used by
the fast path; not part of the consumer API.
Fast path (decode_fast.cc):
- ConsumeDirectives builds Directive / TableDirective structs
inline, conditionally appending to result_ when non-null.
Unmarshal (Result=nullptr) retains its zero-allocation contract:
the fast path still walks and validates directives but allocates
nothing on the prelude.
- New ParseScalarCellValue helper mirrors the scalar branches of
the AST parser's ParseValue. Used by @table row parsing; list /
block cell tokens are already rejected before it's called.
- Body bytes for @<directive> blocks are sliced from
lex_.Input().substr(open + 1, close - (open + 1)) using the
Position::offset added in PR #9.
Tests (14 new in pxf_result_directives_test.cc, 198 total):
- Empty document, bare / single-prefix / multi-prefix directives
- @type does not leak into Directives()
- Nested block body preserved verbatim
- Multiple directives in source order
- @table columns / rows / cells (concrete value tagging)
- Three-state cells (absent / null / value)
- Multiple tables in order
- Directives + tables coexisting
- Unmarshal (no Result) still succeeds (regression check on the
result_-null branch)
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
Third PR in the v0.72–v0.75 cpp catch-up. The fast-path decoder previously walked directives just enough to satisfy the standalone constraint and arity checks; it discarded their content. This PR wires the parsed shape onto `Result` so consumers can read the document-root directive list after `UnmarshalFull` returns.
API additions on `Result`:
Fast path (`decode_fast.cc`):
Test plan