33 lines
554 B
V
33 lines
554 B
V
module main
|
|
|
|
import os
|
|
import strings
|
|
|
|
fn main() {
|
|
content := os.read_file("source.one") or { return }
|
|
println("---------\n" + content + "---------")
|
|
tokens := lex(content) or { return }
|
|
println("-- TOK --")
|
|
print_toks(tokens)
|
|
|
|
mut parser := Parser{
|
|
tokens: tokens
|
|
pos: 0
|
|
}
|
|
statements := parser.parse_program()
|
|
|
|
println("-- AST --")
|
|
println(statements)
|
|
|
|
mut generator := Generator{
|
|
out: strings.new_builder(100)
|
|
}
|
|
|
|
out_c := generator.gen_c(statements)
|
|
|
|
println("--- C ---")
|
|
println(out_c)
|
|
compile_with_clang(out_c, 'test', true)
|
|
|
|
}
|