mighty

The mighty programming language, compiler and tools (WIP)
Log | Files | Refs

commit 27d0fba8abf0dafdbceb58530e88d4a313ae6ed4
parent ae90623b362dda650c5c058d588d360121a18d79
Author: citbl <citbl@citbl.org>
Date:   Sat, 23 May 2026 17:22:38 +1000

wip

Diffstat:
Mmtcl/main.lua | 15+++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/mtcl/main.lua b/mtcl/main.lua @@ -4,16 +4,23 @@ local file = io.open(arg[1], "rb") local contents = file:read("*all") function skip() end -function read_ident(start, c, str) + +function read_ident(start, src) + local word = "" local a = string.byte("a") local z = string.byte("z") local A = string.byte("A") local Z = string.byte("Z") local zero = string.byte("0") local nine = string.byte("9") - for i = start, #str do - local c = src:sub(i,i) + for i = start, #src do + local c = src:sub(i, i):byte() + if not (c >= a and c <= z) and not (c >= A and c <= Z) and not (c >= zero and c <= nine) then + break + end + word = word .. string.char(c) end + print(word) end function lex(src) @@ -32,7 +39,7 @@ function lex(src) if char_fx then char_fx() else - print(c) + read_ident(i, src) end end end