Repository navigation
feat: expose comparison operands as fields - #31
Merged
Merged
Conversation
Label every operand of comparison chains alongside the existing ordered operator fields. Verify public field queries and real incremental edits. Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Reuse the generation-input inventory and include the parser header so a focused comparison regression rejects a stale Wasm artifact. Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
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.
Why
Comparison chains expose their operators but leave their operands unfielded. Tooling must infer the operand list from child positions. This addresses the source-order
operandsrequest intree-sitter/tree-sitter-python#329; a chain can contain more than two operands, so binary left/right fields are insufficient.Requirements
tree-sitter/tree-sitter-python#329by exposing the operands of arbitrary-length comparison chains as fields, alongside the existing operators field; binary left/right fields do not describe a chain.Customer Summary
Every comparison operand is available through the repeated
operandsfield and standard field queries. The existingoperatorsfield remains available in matching source order.Technical Summary
grammar.jslabels the first operand and each repeated subsequent operand with the same field. It adds no wrapper nodes and changes no precedence or token alternatives. Generated parser and schema metadata carry the field to native and Wasm consumers.Testing
Canonical generation, all 207 native and Wasm corpus cases, eight focused tests in six files, and
bun run verifypass. The public API regression checks field traversal, standard queries, exact source ranges and a real incremental edit; published 4.0.0 exposes no operand fields and rejects the query withBad field name 'operands'. A 369-source comparison covers 370 comparison nodes and 1,769 operands, mixed operators and 32/128/512-operand chains; every existing node, range and field is unchanged. The standalone freshness guard shares the existing generation-input inventory and includes the parser header: a manually newer header is rejected, restoring its timestamp makes the public regression pass, and verification passes again. Four bounded manual cases also verify nested comparisons, Unicode/multiline ranges and field-cursor traversal; replacing/deleting an internal operator and undoing both edits match fresh parsing. Full examples/fuzz/browser coverage runs in PR CI.Notes
Seven existing code-gauge errors remain outside the change:
GrammarTests.testFuncdefin both Python2 example variants (159 NCSS), the same function in both Python3 variants (187 NCSS), the Python3.8 example file (1,200 NCSS) and itstest_funcdef(232 NCSS), and the external scanner dispatch (complexity 175/202 NCSS). Refactoring imported grammar fixtures or the unrelated scanner would expand this field change. Forty-six existing warnings remain. The intentional LF/CRLF example duplicates would be suitable for a code-gauge exclusion; no configuration exclusion is added.