Skip to content

feat: recognize brace expansion patterns in Word.parts#18

Merged
mpecan merged 1 commit intomainfrom
feat/brace-expansion-recognition
Apr 7, 2026
Merged

feat: recognize brace expansion patterns in Word.parts#18
mpecan merged 1 commit intomainfrom
feat/brace-expansion-recognition

Conversation

@mpecan
Copy link
Copy Markdown
Owner

@mpecan mpecan commented Apr 7, 2026

Summary

  • Adds post-hoc brace expansion detection ({a,b,c}, {1..10}, {a..z}) to the lexer's span tracking system
  • Exposes BraceExpansion nodes in Word.parts decomposition so downstream consumers (e.g. security tools) can detect brace expansion without runtime evaluation
  • S-expression output is unchanged — brace patterns remain literal in s-exp to match Parable exactly

Changes

  • New module src/lexer/brace_expansion.rs — scans completed words for brace expansion patterns, skipping quoted/escaped/parameter-expansion regions via existing spans
  • WordSpanKind::BraceExpansion — new span kind in word_builder.rs
  • NodeKind::BraceExpansion { content } — new AST node in ast.rs
  • WordSegment::BraceExpansion — new segment variant, wired through is_decomposable() (not is_sexp_relevant)
  • Extracted span_to_segment() helper in sexp/word.rs — reduces build_segments length, collapses three duplicate match arms

Test plan

  • 12 new unit tests in brace_expansion.rs (comma, range, mid-word, nested, empty, single element, trailing/leading comma, param expansion exclusion, adjacent, alpha range, range with step)
  • 3 new decomposition tests in word_parts.rs (comma form, range form, mid-word split)
  • All 168 existing tests pass (including echo {a,b,c}(word "{a,b,c}") s-exp regression)
  • cargo clippy --all-targets -- -D warnings clean

🤖 Generated with Claude Code

Add post-hoc brace expansion detection so downstream consumers
(e.g. security tools) can identify {a,b,c} and {1..10} patterns
in Word.parts without changing s-expression output.

- Add WordSpanKind::BraceExpansion and detect_brace_expansions()
- Add NodeKind::BraceExpansion { content } to AST
- Add WordSegment::BraceExpansion and wire through segment pipeline
- Extract span_to_segment() helper, collapse duplicate match arms
- 15 new unit tests covering comma, range, nested, edge cases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mpecan mpecan merged commit c9fd580 into main Apr 7, 2026
5 checks passed
@mpecan mpecan deleted the feat/brace-expansion-recognition branch April 7, 2026 16:44
mpecan added a commit that referenced this pull request Apr 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.10](rable-v0.1.9...rable-v0.1.10)
(2026-04-07)


### Features

* recognize brace expansion patterns in Word.parts
([fef69dc](fef69dc))
* recognize brace expansion patterns in Word.parts
([#18](#18))
([c9fd580](c9fd580))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant