Skip to content

fix: parser keyword position, ${VAR}/nested $(), lexer comments & fd-redirects, env-prefix#3

Merged
ozhangebesoglu merged 4 commits into
mainfrom
fix/tier2-expander
May 21, 2026
Merged

fix: parser keyword position, ${VAR}/nested $(), lexer comments & fd-redirects, env-prefix#3
ozhangebesoglu merged 4 commits into
mainfrom
fix/tier2-expander

Conversation

@ozhangebesoglu

Copy link
Copy Markdown
Owner

Özet

Denetimde kalan 9 bug, TDD ile düzeltildi (273 test geçiyor, sıfır regresyon). Tier 1 (PR #2) ile birlikte mimari denetimindeki 13 bug'ın tamamı kapandı.

parser

  • Reserved kelimeler (if/while/for/until/case/select) artık yalnızca komut pozisyonunda keyword → grep if file, echo for done tek komut olarak parse edilir.

expander

  • ${VAR} brace genişletme (bare, inline, suffix'li)
  • $(...) dengeli-parantez tarayıcı → iç içe $(echo $(echo x)) çalışır
  • Çift-tırnaklı tanımsız değişken "$X""" (düşürülmüyor); tırnaksız hâlâ word-removal

lexer

  • # yorum (kelime sınırında; kelime/tırnak içinde literal)
  • 1> / 1>> numaralı fd-redirect; &> her iki akışı yönlendirir
  • Karışık tırnak token'ı ('a'"$b") double sentinel taşır → $b expand edilir
  • Tekrar eden quote-prefix mantığı _quote_prefix helper'ına çıkarıldı

executor

  • FOO=bar builtin env-prefix builtin/function çalışırken geçici uygulanır (_temp_env)
  • kishi_setup içinde ulaşılamaz Windows mesajları başarı yoluna taşındı

Test

273 passed — 22 yeni test + 251 mevcut. Çapraz platform (saf Python).

… vars

- ${VAR} brace expansion now works (bare, inline, and with suffix)
- $(...) uses a balanced-paren scanner so nested $(echo $(echo x)) works
  (the whole group is handed to the shell, which evaluates the inner one)
- double-quoted undefined var "$X" yields "" instead of being dropped;
  unquoted undefined var is still removed (word removal)
- '#' at a word boundary starts a comment (literal inside words/quotes)
- numbered fd redirect '1>' / '1>>' map to stdout '>' / '>>'
- '&>' redirects both streams (emits '>' plus a trailing '2>&1')
- a token mixing single + double quotes now carries the double sentinel
  so the $VAR portion is still expanded
- extract repeated quote-prefix logic into Tokenizer._quote_prefix
`if`, `while`, `for`, `until`, `case`, `select` now start a compound
statement only at statement start (current_statement_tokens empty).
Mid-statement they are ordinary arguments, so `grep if file` and
`echo for while done` parse as a single command instead of splitting.
…etup

- `FOO=bar builtin` now applies the env prefix while the builtin/function
  runs (parent process), restoring prior values afterwards via _temp_env
- kishi_setup: the Windows success messages were unreachable (mis-indented
  inside the except block after `return 1`); moved to the success path

Note: the kishi_setup branch is Windows-only and not exercised by the
Linux CI; the change is a straightforward control-flow correction.
@ozhangebesoglu ozhangebesoglu merged commit 328a441 into main May 21, 2026
5 checks passed
@ozhangebesoglu ozhangebesoglu deleted the fix/tier2-expander branch May 21, 2026 14:49
ozhangebesoglu added a commit that referenced this pull request May 21, 2026
Tier 2 bugfix release: parser keyword position, ${VAR}/nested $()
expansion, lexer comments & fd-redirects, mixed-quote tokens, and
VAR=value env prefix on builtins (PR #3).
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