-
This commit is contained in:
@@ -73,9 +73,8 @@ fn (mut g Generator) gen_expr(expr Expr) {
|
||||
PrintExpr {
|
||||
g.out.write_string('printf(\"%')
|
||||
format := match expr.type {
|
||||
'int' {'d'}
|
||||
'int', 'bool' {'d'}
|
||||
'real' {'lf'}
|
||||
'bool' {'d'}
|
||||
else {panic("Tried printing illegal type")}
|
||||
}
|
||||
g.out.write_string('${format}\\n\", ')
|
||||
|
||||
16
main.v
16
main.v
@@ -7,17 +7,23 @@ fn main() {
|
||||
content := os.read_file("source.one") or { return }
|
||||
println("---------\n" + content + "---------")
|
||||
tokens := lex(content) or { return }
|
||||
println("-- TOK --")
|
||||
print_toks(tokens)
|
||||
|
||||
$if debug {
|
||||
println("-- TOK --")
|
||||
print_toks(tokens)
|
||||
}
|
||||
|
||||
mut parser := Parser{
|
||||
tokens: tokens
|
||||
pos: 0
|
||||
}
|
||||
|
||||
statements := parser.parse_program()
|
||||
|
||||
println("-- AST --")
|
||||
println(statements)
|
||||
$if debug {
|
||||
println("-- AST --")
|
||||
println(statements)
|
||||
}
|
||||
|
||||
mut generator := Generator{
|
||||
out: strings.new_builder(100)
|
||||
@@ -25,8 +31,6 @@ fn main() {
|
||||
|
||||
out_c := generator.gen_c(statements)
|
||||
|
||||
println("--- C ---")
|
||||
println(out_c)
|
||||
compile_with_clang(out_c, 'test', true)
|
||||
|
||||
}
|
||||
|
||||
1
parser.v
1
parser.v
@@ -86,7 +86,6 @@ fn (mut s SymbolTable) lookup_func(name string) ?FuncSymbolInfo {
|
||||
}
|
||||
|
||||
fn (mut s SymbolTable) is_in_global_scope() bool {
|
||||
println("scope count: ${s.variable_scopes.len}")
|
||||
return s.variable_scopes.len == 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user