Skip to content

Commit 0c411f8

Browse files
Testclaude
andcommitted
feat: implement quote processing (Phase 6 M13)
Milestone 13 complete: POSIX-compliant quote processing with quote-aware glob expansion integration. ## New Module - src/quotes.rs (~600 lines): - QuoteState enum: Unquoted, SingleQuoted, DoubleQuoted - QuotedSegment struct: text + quote state pairing - parse_quotes(): Full POSIX quote parser - should_expand_glob(): Quote-aware glob pattern detection - reconstruct_string(): Segment reconstruction helper - 17 unit tests (all passing) ## Parser Integration - Modified src/parser.rs: - quoted_word_to_string(): Now escapes glob metacharacters (*, ?, [, {) in quoted contexts (both single and double quotes) - Escaped patterns prevent glob expansion via contains_glob_pattern() - Preserves existing variable expansion handling ## POSIX Quote Semantics - Single quotes ('...'): - All characters literal, no expansion whatsoever - Cannot contain single quote (even escaped) - Whitespace preserved - Double quotes ("..."): - Variable expansion: $VAR, ${VAR} - Command substitution: $(cmd), `cmd` - Arithmetic expansion: $((expr)) - NO glob expansion (patterns stay literal) - Backslash escapes: \$, \`, \", \\, \newline - Backslash (unquoted): - Escapes next character literally - Line continuation: backslash-newline removed ## Quote + Glob Integration - Quoted globs don't expand: - '*.txt' → stays literal "*.txt" - "*.txt" → stays literal "*.txt" - Unquoted globs expand: - *.txt → file1.txt file2.txt - Escaped globs don't expand: - \*.txt → stays literal "*.txt" ## Testing - All 157 library tests passing (including 17 quote tests) - Integration verified: escaped glob patterns not detected - Quote behaviors: whitespace, escaping, line continuation ## State Updates - STATE.scm: - Overall completion: 85% → 90% - Phase: M12 Complete → M13 Complete - Removed "Quote processing not implemented" blocker - Added quote processing + quote-aware glob to working-features - Added session history entry ## Documentation - docs/PHASE6_M13_DESIGN.md: Complete design document (800+ lines) Phase 6 progress: 13/14 milestones complete (90%) Next: M14 Full POSIX shell compliance (final milestone) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6d7f3ec commit 0c411f8

5 files changed

Lines changed: 1486 additions & 14 deletions

File tree

STATE.scm

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
(version . "0.14.0"))
2727

2828
(current-position
29-
(phase . "Phase 6 M12 Complete - Glob Expansion Operational")
30-
(overall-completion . 85)
29+
(phase . "Phase 6 M13 Complete - Quote Processing Integrated")
30+
(overall-completion . 90)
3131

3232
(components
3333
(proofs
@@ -73,6 +73,8 @@
7373
"Here documents (<<DELIMITER with expansion and <<-DELIMITER with tab stripping)"
7474
"Here strings (<<<word for single-line input)"
7575
"Glob expansion (*.txt, file?.rs, [a-z]*, {1,2,3}, brace expansion)"
76+
"Quote processing (single quotes, double quotes, backslash escaping)"
77+
"Quote-aware glob expansion (quoted patterns don't expand)"
7678
"Redirection undo support (file truncate/append reversible)"
7779
"Pipeline undo support (final redirections reversible)"
7880
"SIGINT handling (Ctrl+C interrupts commands/pipelines, not shell)"
@@ -193,8 +195,7 @@
193195
(critical
194196
"Formal Lean → Rust correspondence proofs still needed (mechanized verification)")
195197

196-
(high
197-
"Quote processing not implemented (Phase 6 M13)")
198+
(high)
198199

199200
(medium
200201
"Full POSIX compliance (subset) - Phase 6 M14"
@@ -224,6 +225,35 @@
224225
"Begin Lean 4 → Rust correspondence proofs"))
225226

226227
(session-history
228+
((timestamp . "2026-01-29")
229+
(session . "phase6-m13-quote-processing")
230+
(accomplishments
231+
"Completed Phase 6 Milestone 13: Quote Processing"
232+
"Created comprehensive quote module (src/quotes.rs, ~600 lines):"
233+
" - QuoteState enum: Unquoted, SingleQuoted, DoubleQuoted"
234+
" - QuotedSegment struct: content + state pairing"
235+
" - parse_quotes(): POSIX-compliant quote parser"
236+
" - should_expand_glob(): Quote-aware glob detection"
237+
" - reconstruct_string(): Segment reconstruction"
238+
" - 17 unit tests covering all quote behaviors"
239+
"Integrated with existing parser quote handling:"
240+
" - Modified quoted_word_to_string() to escape glob metacharacters in quotes"
241+
" - Escapes *, ?, [, { in single and double quotes"
242+
" - Escaped patterns prevent glob expansion (via contains_glob_pattern())"
243+
" - Preserves whitespace in quoted strings"
244+
"POSIX-compliant quote semantics:"
245+
" - Single quotes: all characters literal, no expansion"
246+
" - Double quotes: variable/command expansion, no glob expansion"
247+
" - Backslash escaping: unquoted and in double quotes"
248+
" - Line continuation: backslash-newline removed"
249+
"Quote + Glob integration:"
250+
" - Quoted globs don't expand: '*.txt', \"*.txt\" stay literal"
251+
" - Unquoted globs expand: *.txt → file1.txt, file2.txt"
252+
" - Escaped globs don't expand: \\*.txt stays literal"
253+
"All 157 library tests passing (including 17 quote tests)"
254+
"Integration test verified: escaped globs not detected as patterns"
255+
"Phase 6 progress: 13/14 milestones complete (90%)"
256+
"Next: M14 Full POSIX compliance (final milestone)"))
227257
((timestamp . "2026-01-29")
228258
(session . "phase6-m12-glob-expansion")
229259
(accomplishments

0 commit comments

Comments
 (0)