Repository navigation
feat: nodes didn't know where in the source they came from - #102
Merged
Merged
Conversation
Syncs Netweir 04cc3bc (netweir/netweir#329). With Options { spans: true, .. }, the parser records each node's and attribute's byte range in the input as passed (CRLFs and a byte order mark mapped back): Document::span, end_span, attr_span, and line_col for a line and column. Off by default, so a plain parse costs what it did. Options gained a field, so the C API and both bindings fill the rest with Options::default(). .gitattributes keeps the tree-construction .dat files' LFs on a Windows checkout, where they had been turned into CRLFs.
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.
Problem
Lexbor's nodes don't know where they came from (lexbor#374, lexbor#388), and neither did Parsec's (#8). Editors, linters and anything that reports back to a person need it.
Change
Options { spans: true, .. }:Document::spangives an element's start tag, or the whole of a text, comment, doctype or PI.end_spangives the end tag, andattr_spanan attribute's name through its value.line_colturns one into a 1-based line and column..gitattributes: keepscrates/parsec/tests/tree-construction/*.datbyte for byte on Windows. A Windows checkout had turned their LFs into CRLFs, which the new span test caught.parsec-capi,bindings/python,bindings/wasm: buildOptionswith..Options::default(), since it gained a field.Closes #8
Tests
cargo test --workspace: 231 test groups, 0 failed. The newtests/spans.rschecks 13,626 spans over every tree-construction case, plus hand-written ones with CRLF, entities, foster parenting and unquoted attributes.-D warningsis clean on the workspace,bindings/pythonandbindings/wasm(wasm32).