migrate to new mutable decl syntax

This commit is contained in:
2026-08-05 21:53:09 +02:00
parent 1689c4db3c
commit 410246faee
20 changed files with 116 additions and 112 deletions
+1
View File
@@ -1,6 +1,7 @@
import "@source/lexer"
hide TokenId :: alias lexer.TokenId
hide Token :: alias lexer.Token
NodeId :: distinct u32
ExtraId :: distinct u32
+4 -4
View File
@@ -66,7 +66,7 @@ scan proc(state @mut State, program []u8) void ! (mem.AllocError | strpool.Inter
tokens :: &state.tokens
diagnostics :: &state.diagnostics
cursor usize = 0
cursor usize := 0
while cursor < program.len {
char :: program[cursor]
@@ -208,8 +208,8 @@ ScanNumResult :: struct {
}
scan_number proc(start usize, program []u8) ScanNumResult ! ScanError {
cursor usize = start
has_decimal bool = false
cursor := start
has_decimal := false
# scan integer part
while (cursor < program.len and is_digit(program[cursor])) cursor += 1
@@ -237,7 +237,7 @@ scan_number proc(start usize, program []u8) ScanNumResult ! ScanError {
ScanStrResult :: struct { end usize }
scan_string proc(start usize, program []u8) ScanStrResult ! ScanError {
cursor usize = start + 1 # skip first `"`
cursor := start + 1 # skip first `"`
# scan entire string
while cursor < program.len and program[cursor] != '"' and program[cursor] != '\n' : cursor += 1 {
+1 -1
View File
@@ -6,7 +6,7 @@ handles_keywords_identifiers_and_error_progress test {
strpool.strings = strpool.init(mem.c_allocator)
defer strpool.deinit(&strpool.strings)
state State = init(mem.c_allocator)
state State := init(mem.c_allocator)
defer deinit(&state)
try scan(&state, "if name # comment\n@1. 2 3.5 \"hi\"")
+5 -2
View File
@@ -10,10 +10,12 @@ test import "@std/strmap"
import "@source/strpool"
import "@source/lexer"
import "@source/parser"
import "@source/ast"
test import "@source/strpool"
test import "@source/lexer"
program ::
`# literals
`x int :: 123.9
@@ -25,7 +27,7 @@ main proc() void {
debug.print("PROGRAM::[[\n{}\n]]\n\n", {program})
scan_state lexer.State = lexer.init(mem.c_allocator)
scan_state := lexer.init(mem.c_allocator)
defer lexer.deinit(&scan_state)
lexer.scan(&scan_state, program) catch |err| {
@@ -46,7 +48,7 @@ main proc() void {
}
debug.print("]]\n\n", {})
parse_state parser.State = parser.init(mem.c_allocator)
parse_state := parser.init(mem.c_allocator)
defer parser.deinit(&parse_state)
parser.parse(&parse_state, scan_state.tokens.items) catch |err| {
debug.print("failed to parse: {}\n", {err})
@@ -85,6 +87,7 @@ main proc() void {
scan_state.tokens.items,
program,
) catch "<invalid>"
debug.print("generated literal: {}\n", { literal })
debug.print("]]\n", {})
}
+1 -1
View File
@@ -3,7 +3,7 @@ import "@std/arraylist"
import "@std/hashmap"
# cross-cutting concern, hence global singleton (owned by main.hon)
strings StringPool = undefined
strings StringPool := undefined
InternError :: enum { out_of_space }
+2 -2
View File
@@ -2,10 +2,10 @@ import "@std/mem"
import "@std/testing"
handles_intern test {
pool StringPool = init(mem.c_allocator)
pool StringPool := init(mem.c_allocator)
defer deinit(&pool)
input [5]mut u8 = ['h', 'e', 'l', 'l', 'o']
input [5]mut u8 := ['h', 'e', 'l', 'l', 'o']
id :: try intern(&pool, input[..])
duplicate :: try intern(&pool, "hello")
input[0] = 'j'