feat: enrich AST with spans, structured lists, and pipe separators#7
Merged
feat: enrich AST with spans, structured lists, and pipe separators#7
Conversation
…ssignments
Add source position tracking, structured command lists, pipe operator
metadata, and separated variable assignments based on downstream developer
feedback. S-expression output remains byte-identical to Parable.
- Rename `Node` enum to `NodeKind`, wrap in `Node { kind, span }` struct
- Add `Span { start, end }` with `source_text()` convenience method
- Add `assignments` field to `Command` (separate from `words`)
- Replace `List { parts }` with `List { items: Vec<ListItem> }` using
typed `ListOperator` enum; remove `Operator` variant
- Add `separators: Vec<PipeSep>` to `Pipeline`; remove `PipeBoth` variant
- Add tests for new structural features
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ailures - Fix format_list dropping trailing operators (e.g., `cmd &` in command substitutions lost the `&`) by writing the last item's operator - Assert on Parable compatibility test failures so CI catches regressions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the single monolithic `parable_test_suite` test with 36 individual `#[test]` functions (one per .tests file) using a declarative macro. Each file now appears as a separate test in `cargo test` output, making failures easier to identify and allowing targeted re-runs like `cargo test parable_12_command_substitution`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mpecan
added a commit
that referenced
this pull request
Mar 25, 2026
🤖 I have created a release *beep* *boop* --- ## [0.1.6](rable-v0.1.5...rable-v0.1.6) (2026-03-25) ### Features * enrich AST with spans, structured lists, and pipe separators ([#7](#7)) ([53269b7](53269b7)) * enrich AST with spans, structured lists, pipe separators, and assignments ([7eec43e](7eec43e)) * improve Rust developer experience ([2ac7654](2ac7654)) ### Bug Fixes * trailing list operators in format and assert on Parable compat failures ([3a98be1](3a98be1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
3 tasks
mpecan
added a commit
that referenced
this pull request
Mar 25, 2026
## Summary Follows up on #7 (AST enrichment) to actually populate spans on all nodes. - Add `last_token_end` tracking to Lexer for precise span endpoints - Add `peek_pos()`, `span_from()`, `spanned()` helpers to Parser - Populate spans on all node types: Command, Word, Pipeline, List, Redirect, HereDoc, compound commands, conditional expressions, Negation, Time - Fix `source_text()` char-index-to-byte-offset conversion - 17 span coverage tests (100% line coverage on span logic) ## Test plan - [x] 103 tests pass (60 unit + 37 integration + 6 doc) - [x] `cargo clippy --all-targets -- -D warnings` clean - [x] Span-related code in ast.rs at 100% line coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
Nodeenum →NodeKind, wrap inNode { kind: NodeKind, span: Span }struct withsource_text()convenience methodCommandvariant gainsassignments: Vec<Node>field distinct fromwords(ready for lexerAssignmentWordsupport)List { parts: Vec<Node> }(interleaved commands/operators) withList { items: Vec<ListItem> }using typedListOperatorenum; removeOperatorvariantseparators: Vec<PipeSep>toPipelinedistinguishing|from|&; removePipeBothnode variantMotivation
Downstream developer feedback identified the lack of source positions and structured metadata as the primary pain point when consuming the AST. This eliminates the need for fragile workarounds like
source.find(word), scanning for operators by string matching, andlooks_like_assignment()heuristics.Test plan
cargo clippy --all-targets -- -D warningscleancargo fmt --checkcleanListItemstructure,PipeSep,Command.assignments,source_text()🤖 Generated with Claude Code