Initial commit

This commit is contained in:
Hugo Mårdbrink 2025-08-01 23:16:51 +02:00
commit 3e2b956786
6 changed files with 559 additions and 0 deletions

48
main.odin Normal file
View file

@ -0,0 +1,48 @@
package main
import "core:os"
import "core:fmt"
import "core:log"
import "core:mem"
import "parser"
import "shell"
INPUT_MAX :: 4096
main :: proc() {
track: mem.Tracking_Allocator
mem.tracking_allocator_init(&track, context.temp_allocator)
context.temp_allocator = mem.tracking_allocator(&track)
defer {
if len(track.allocation_map) > 0 {
fmt.eprintf("=== %v allocations not freed: ===\n", len(track.allocation_map))
for _, entry in track.allocation_map {
fmt.eprintf("- %v bytes @ %v\n", entry.size, entry.location)
}
}
mem.tracking_allocator_destroy(&track)
}
buf: [INPUT_MAX]byte
for true {
prompt := shell.get_prompt()
fmt.print(prompt)
buf_len, err := os.read(os.stdin, buf[:])
log.assertf(err == nil, "Error reading input")
input := string(buf[:buf_len])
cmd_seq, parser_err := parser.parse(input)
log.assertf(parser_err == nil, "Could not parse input")
stop := shell.execute(&cmd_seq)
free_all(context.temp_allocator)
if stop == .Stop do break
}
}