Commit Graph

15 Commits

Author SHA1 Message Date
abdussamedulutas 580f9f8c5f chore: .gitignore — CMake versiyona özgü dosyaları hariç tut
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 19:52:33 +03:00
abdussamedulutas 539e08e521 feat(vm): string veri tipi + run pipeline'ına TypeChecker eklendi
- Value: ValueKind::String + stringValue alanı eklendi
- instruction: LOAD_STRING opcode'u eklendi
- ir_generator: STRING literal → LOAD_STRING; desteklenmeyen tipler
  (FLOAT, null) IR üretim aşamasında hata fırlatır
- interpreter: runtime tip kontrolleri kaldırıldı (TypeChecker zaten
  derleme zamanında tipleri doğruluyor); sıfıra bölme kontrolü kaldı
  (gerçek çalışma zamanı koşulu); print() string/int ayırt eder
- run.hpp: TypeChecker + StructuralValidator pipeline'a eklendi

Test:
  build/saqut run file:examples/merhaba.sqt → Merhaba / saQut calisiyor
  build/saqut run file:examples/fibonacci.sqt → 55 / 55

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 19:46:48 +03:00
abdussamedulutas a4bd5110b3 chore(ir): dump formatını sade yap — NAME=... PARAMS=... SLOTS=...
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 19:29:32 +03:00
abdussamedulutas 7c7f886e9c feat(cli): saqut ir komutu — IR talimat dump'u
- IRFunction::dump() yenilendi: ASCII kutu, sn slot notasyonu,
  ikili op'larda sembol (+/-/*/<= vb.), hizalı sütunlar
- src/cli/commands/ir.hpp: tokenize→parse→collect→ir→dump pipeline
- main.cpp + args.hpp: "ir" komutu kayıtlı

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 19:21:12 +03:00
abdussamedulutas 9b486942c0 feat(ir-vm): fibonacci.sqt çalışıyor — IR üretici + bytecode VM
IR instruction seti (14 opcode): LOAD_CONST, LOAD_SLOT, ADD/SUB/MUL/DIV/MOD,
LESS/LEQ/GT/GEQ/EQ/NEQ, JMP, JIF_FALSE, CALL, RETURN, CALLHOST

IRGenerator (AST → IR):
  - Slot tabanlı register: parametreler slot 0..n, lokaller/geçiciler sonrası
  - freshSlot() monoton sayaç — slot asla geri verilmez
  - Backpatch: ileri-jump için emitJumpIfFalse(-1) → patchJump(idx)
  - Geri-jump: loopStart = currentInstrIndex() → emitJumpUnconditional(loopStart)
  - Builtin tespiti: resolvedSymbol->isBuiltin → CALLHOST

Interpreter (bytecode VM):
  - Her iterasyonda callStack.back() taze alınır (referans güvenliği)
  - CALL: yeni frame + argüman kopyası + continue
  - RETURN: değer caller slotuna, frame pop + continue
  - ip CALL/RETURN'den önce ilerler — caller doğru noktadan devam eder
  - DIV: sıfıra bölme → runtime_error

Doğrulama:
  build/saqut run file:examples/fibonacci.sqt → 55 / 55 ✓
  tests/run.sh → TUM TESTLER GECTI ✓

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 19:17:30 +03:00
abdussamedulutas 8453dcd796 chore: CLAUDE.md güncelle + gen_large.py + large.sqt ekle
- CLAUDE.md: Faz 2/3 tamamlandı, yeni komutlar (check), nlohmann/json,
  semantic/ klasörü, performans optimizasyonu notları güncellendi
- scripts/gen_large.py: 2.3MB geçerli .sqt dosyası üreten benchmark script'i
- examples/large.sqt: 5000 fonksiyon, 90K satır, performans test fixture'ı

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 18:40:30 +03:00
abdussamedulutas 2b9888c021 perf(tokenizer): switch dispatch + unordered_map keyword lookup
Önceki: for döngüsü içinde her token için include() 63 kez çağrılıyordu
        → 66.9M include() çağrısı, zamanın %81'i

Sonraki:
  - Operatör/delimiter: switch(c0) + getchar(1) ile O(1) dispatch
  - Keyword: readIdentifier() → unordered_map::find() O(1) lookup
  - include() yalnızca // /* */ için (2-3 çağrı/yorum satırı)

Sonuç (2.3MB, 90K satır, debug build):
  tokens: 11.5s → 2.4s  (−79%)
  check:  12.7s → 3.7s  (−71%)

gprof ÖNCE: %81 include() (66.9M çağrı)
gprof SONRA: include() %0.00 — artık ölçülemez

Profil dosyaları: docs/perf-before.txt, docs/perf-after.txt

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 18:35:10 +03:00
abdussamedulutas aa4d9fb8c2 perf: include() parametresini std::string → std::string_view yap
Tokenizer her token için ~84 kez include() çağırıyor.
Önceki imza std::string (değer kopyası) aldığından her çağrıda
heap allocation yapılıyordu. string_view + explicit std::string()
cast'larının kaldırılmasıyla 2.3 MB dosyada tokens süresi
17.6s → 11.9s (−32%).

Kök neden: src/tokenizer/tokenizer.cpp satır 44/61/73'teki
std::string(kw/del/op) explicit cast'ları string_view tablolardan
gereksiz kopya üretiyordu.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 18:03:54 +03:00
abdussamedulutas e84828b631 feat(faz3): semantik analiz — tip denetimi + yapısal doğrulama (#72)
- src/semantic/type_checker: her ExpressionNode'a resolvedType atar
  * literal bağlama-göre tiplenir (float x = 1 → uyarısız)
  * değişken→değişken genişletme → W004
  * daraltma / farklı tip → E003
  * fonksiyon çağrısı argüman sayısı/tipi → E008
  * return tipi uyumsuzluğu → E003 (checkAssign üzerinden)
- src/semantic/structural_validator: kontrol akışı kuralları
  * break/continue döngü dışı → E004
  * return fonksiyon dışı → E005
- W004 diagnostic kataloğa eklendi
- saqut check komutu: tokenize→parse→collect→typecheck→validate
- examples/semantic/: widening, narrowing, bad_return, break_outside, bad_args
- MISSION-FAZ3.md eklendi

Doğrulama:
  fibonacci.sqt → 0 hata 0 uyarı ✓
  widening.sqt  → W004 ✓
  narrowing.sqt → E003 ✓
  break_outside.sqt → E004 ✓
  bad_args.sqt  → E008 ✓
  tests/run.sh  → TUM TESTLER GECTI ✓

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 17:20:06 +03:00
abdussamedulutas b071dab54c feat(symbols): --compact bayrağı + referenceCount alanı
- CliArgs'e compact bool eklendi; --compact ile boşluksuz JSON çıktısı
- symbols çıktısında her sembol için referenceCount (references.size()) alanı eklendi
- fibonacci.sqt onarıldı: araç hatası sonucu silinen '{' geri konuldu

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 16:44:03 +03:00
abdussamedulutas dc41a5df59 refactor: nlohmann/json entegrasyonu — string birleştirme yerine nesne API
- src/vendor/nlohmann/json.hpp eklendi (single-header, MIT)
- SourceLocation  → toJsonObj() + toJson() (nlohmann)
- Type            → toJsonObj() + toJson() (nlohmann, özyinelemeli)
- Diagnostic      → toJsonObj() + toJson() (nlohmann)
- DiagnosticEngine→ toJsonObj() + toJson() (nlohmann)
- symbols.hpp     → tamamen nlohmann ile yeniden yazıldı

Tüm toJson() imzaları std::string döndürmeye devam eder;
AST JsonObject builder'ı dokunulmadı (ayrı katman).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 16:21:58 +03:00
abdussamedulutas e223995f20 feat(symbols): JSON çıktı + syntax hata toleransı
- symbols komutu artık JSON üretiyor: file, symbols[], diagnostics
  Her sembol: name, kind, type, typeDetail, definition (file+satır+sütun),
  references[], isBuiltin — LSP tüketimine hazır format
- parser: parseProgram() ilerleme olmayana token atla (guard ekle)
  Bozuk top-level syntax (ör: `}`, eksik parametre listesi) artık
  ayrıştırmayı durdurmak yerine sonraki geçerli bildirimi bulmaya devam eder

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 16:11:34 +03:00
abdussamedulutas ba08bf4511 feat(faz2): sembol tablosu — isim çözümleme + scope + referans toplama (#71)
- parser: parseFunctionDecl() parametreleri artık AST'ye alıyor
  (FunctionDeclNode::params alanı eklendi; declarations.hpp/cpp güncellendi)
- parser: parseDeclaration() kullanıcı-tanımlı tip (struct alanı) desteği
- ast_json: addArray() m_hasArrayItem sıfırlama hatası düzeltildi
  (birden fazla dizi alanı içeren düğümlerde bozuk JSON üretimi giderildi)
- src/symbol/: Symbol, Scope, SymbolTable, SymbolCollector eklendi
  * İki geçiş: pass1 global hoist, pass2 gövde + declare-before-use
  * E001 tanımsız isim, E002 çift tanım, E010 döngüsel struct
  * print builtin tohumlama (TODO: #89 katalog)
- cli/symbols: yeni SymbolTable/Collector kullanıyor; tip + refs çıktısı
- examples/symbols/: dup.sqt, undef.sqt, cyclic.sqt test fixture'ları

Doğrulama:
  build/saqut symbols file:examples/fibonacci.sqt → 0 hata, 10 sembol
  examples/symbols/dup.sqt → E002
  examples/symbols/undef.sqt → E001
  examples/symbols/cyclic.sqt → E010
  tests/run.sh → TUM TESTLER GECTI
  AST JSON → geçerli

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 15:43:26 +03:00
abdussamedulutas 7c5a86c39b fix: kaynak dosya yolu propagasyonu ve AST JSON girinti hataları
- Tokenizer::scan artik filePath parametresi alip Lexer'a iletiyor;
  SourceLocation.file artik bos degil (Asama 0 tamamlandi).
- JsonObject::add icin const char* overload eklendi (kind: true bug'i).
- JsonObject acilis suslu parantezi girintisiz yaziliyor, addArray ilk
  eleman oncesi bos satir birakmiyor; LiteralNode/IdentifierNode toJson
  ayni sekilde duzeltildi.
- analysisToJson girinti seviyeleri "analysis" objesine gore duzeltildi.
2026-06-14 15:57:54 +03:00
abdussamedulutas 93cbc7db3a Gemini 2026-05-27 10:29:30 +03:00