Commit Graph
6 Commits
Author SHA1 Message Date
waozi 69eb7b3629 Extract Kir parser into shared kir_parse.c (prerequisite for k2c/k2b backends)
The .kry -> Kir parser is now a shared library (cmd/kir/kir_parse.c +
kir_parse.h) exposing kir_parse_file(path, root) -> KirProgram*. Both k2c
(the C backend) and k2b (the krb backend) can link it to share one frontend.

k2ir/main.c is now a thin wrapper: parse + KirProgramDump to a .kir file.
The output path uses the module's source_path to preserve directory structure.

k2ir_test passes; make test green. The k2c backend (Stage 2) can now link
kir_parse.c to get Kir input.
2026-08-13 22:07:11 -05:00
waozi 02c07c823e k2ir: parse app{} metadata (title/size/fps/theme/frame/init/scene/shutdown)
Add KirAppMeta to KirModule (has_app, title, dimensions, fps, theme,
dark_mode, font_examples, frame/init/scene/shutdown hooks). The k2ir frontend
gains an APP mode that parses the app{} block's properties, and the dump
prints the metadata. This is needed by the future k2c backend to generate
main() (hook-driven / scene-tree / single-screen variants).
2026-08-13 21:57:34 -05:00
waozi 5829318c66 k2ir: multi-line statement joining (paren/bracket/string depth tracking)
The k2ir frontend now joins physical lines into logical lines while ()/[]
depth > 0 or a string is open, so multi-line widget calls like
  Button((ButtonProps){
    .bounds = ...,
    .label = ...,
  })
become one classified statement. Braces at paren depth 0 are NOT join
triggers (block openers end the line). A pending buffer accumulates, a
static copy is dispatched, and pending is reset before the dispatch (so
mode-dispatch 'continue' paths are safe).

Also: classify mutations (count++) as EXPR not UNKNOWN, and initialize the
pending buffer (was uninitialized — strncat found garbage null bytes).

Verified: k2ir test passes; multi-line Button calls join correctly; make test
green.
2026-08-13 20:56:22 -05:00
waozi 56e10300ae k2ir: classify mutations (count++) as EXPR not UNKNOWN
The classify_stmt heuristic missed bare mutations like 'count++' / 'count--'
(no ':=', '=', or '(' tokens). Extend the EXPR match to include '+'/'-' so
post/pre-increment classify correctly. The k2ir frontend still needs
multi-line statement joining for real-world .kry (the next increment).
2026-08-13 20:29:39 -05:00
waozi 4f0d1874cc Teach k2ir about imports and externs 2026-08-13 11:38:58 -03:00
waozi c89e034ef4 Add k2ir tool scaffold 2026-08-13 11:31:30 -03:00