mighty

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

commit 6771a98d86a09d29fa22b68ea33037624db8469c
parent 86e49fcd2661662b02ef226160fa9c87a5434386
Author: citbl <citbl@citbl.org>
Date:   Sat, 16 May 2026 17:19:23 +1000

line comments

Diffstat:
Mmtc/lexer/lexer.go | 9+++++++++
Mmtc/main.go | 6+++++-
Amtc/mighty | 0
Mmtc/target.mty | 10+++++-----
Mmtc/test.mty | 2++
5 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/mtc/lexer/lexer.go b/mtc/lexer/lexer.go @@ -43,6 +43,7 @@ func Lex(src string) []Token { for i < len(src) { c := src[i] + if is_space(c) { if c == '\n' { line++ @@ -95,6 +96,14 @@ func Lex(src string) []Token { if i+1 < len(src) { cx = src[i+1] } + if c == '/' && cx == '/' { + for i < len(src) && src[i] != '\n' { + i++ + col++ + } + continue + } + switch c { case '.': res = append(res, Token{Dot, src[i : i+1], line, col}) diff --git a/mtc/main.go b/mtc/main.go @@ -9,7 +9,11 @@ import ( func main() { args := os.Args[1:] - fmt.Println(args[0]) + if len(args) != 1 { + fmt.Println("usage: ./mtc file.mty") + return + } + data, err := os.ReadFile(args[0]) if err != nil { panic(err) diff --git a/mtc/mighty b/mtc/mighty Binary files differ. diff --git a/mtc/target.mty b/mtc/target.mty @@ -5,8 +5,8 @@ int main() :: // target QBE: -export function w $add(w %a, w %b) { -@start - %r =w add %a, %b - ret %r -} +//export function w $add(w %a, w %b) { +//@start +// %r =w add %a, %b +// ret %r +//} diff --git a/mtc/test.mty b/mtc/test.mty @@ -1,3 +1,5 @@ +// test comment + int main() :: io.putln("hello world") io.putln("hello " + 123)