lang F1: range-based for + inline-for unroll over packs

Add range loop syntax:
- runtime  for start..end (i) { }   counting loop, cursor optional, end exclusive
- comptime inline for start..end (i) { }   comptime-unrolled body

The inline form binds the cursor as an int_val comptime constant per
iteration, so xs[i] over a heterogeneous pack substitutes the concrete
per-position element -- the canonical's pack-iteration vehicle
(inline for 0..sources.len (i) { sources[i].addListener(...) }).

- AST: ForExpr.range_end, ForExpr.is_inline
- parser: parseForExpr range vs collection form; suppress_call flag so
  N (i) is not read as a call N(i) while parsing a range bound
- lower: lowerRuntimeRangeFor / lowerInlineRangeFor; evalComptimeInt;
  comptimeIndexOf extends pack-index resolution beyond int literals

Revises spec's inline for i in 0..N to the no-in, range-first, paren-cursor
form. Regression: examples/200-for-range.sx.
This commit is contained in:
agra
2026-05-29 21:36:17 +03:00
parent 27fd5e1e6a
commit 27c88d4d26
7 changed files with 305 additions and 29 deletions

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1,10 @@
i=0
i=1
i=2
n=5
j=2
j=3
j=4
[0]=A
[1]=B
[2]=A