infer var type when initializer is a number constant

This commit is contained in:
2025-12-23 18:10:56 +01:00
parent 5682318915
commit c527aceecd
36 changed files with 118 additions and 100 deletions

View File

@@ -2,11 +2,11 @@ func main[] : i64
// https://brainfuck.org/sierpinski.b
let src: str = "++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<]>.>+[>>]>+]"
let src_len: i64 = str.len(src)
let i: i64 = 0
let i = 0
let memory: ptr = mem.alloc(30000)
mem.zero(memory, 30000)
let p: i64 = 0
let p = 0
while i < src_len
let op: u8 = src[i]
@@ -26,7 +26,7 @@ func main[] : i64
else if op == '['
if !memory[p]
i = i + 1
let opened: i64 = 0
let opened = 0
while i < src_len & !(src[i] == ']' & !opened)
if src[i] == '['
opened = opened + 1
@@ -36,7 +36,7 @@ func main[] : i64
else if op == ']'
if memory[p]
i = i - 1
let closed: i64 = 0
let closed = 0
while i >= 0 & !(src[i] == '[' & !closed)
if src[i] == ']'
closed = closed + 1