Executable vrmm

This commit is contained in:
allexanderbergmns
2026-08-25 14:47:59 +02:00
parent 387079d720
commit 012c8a0e16
4 changed files with 53 additions and 1 deletions
+9 -1
View File
@@ -2,7 +2,15 @@
module compiler
pub fn tokenize(src string) ![]Tok {
mut l := Lexer{ src: src, line: 1 }
// a script may start with a shebang line (#!...) so it can be executed
// directly (e.g. `#!/usr/bin/env vr`). Drop it, but keep the trailing
// newline so error line numbers stay aligned with the file on disk.
mut s := src
if s.starts_with('#!') {
nl := s.index('\n') or { s.len }
s = s[nl..]
}
mut l := Lexer{ src: s, line: 1 }
mut toks := []Tok{}
for {
t := l.next()!