2019-12-29 10:51:55 +03:00
|
|
|
module main
|
|
|
|
|
|
|
|
import (
|
|
|
|
v.parser
|
|
|
|
v.table
|
2019-12-30 10:30:24 +03:00
|
|
|
v.gen
|
2019-12-29 10:51:55 +03:00
|
|
|
os
|
|
|
|
)
|
|
|
|
|
2019-12-30 08:16:59 +03:00
|
|
|
const (
|
|
|
|
cdefs = '
|
|
|
|
#define true 1
|
|
|
|
#define false 0
|
2019-12-30 10:30:24 +03:00
|
|
|
typedef int bool;
|
2019-12-30 08:16:59 +03:00
|
|
|
typedef struct { char* str; } string;
|
|
|
|
typedef double f64;
|
2020-01-02 10:37:41 +03:00
|
|
|
string tos3(char* s) { return (string){ .str = s, len = strlen(s) }; }
|
2019-12-30 08:16:59 +03:00
|
|
|
')
|
|
|
|
|
2019-12-29 10:51:55 +03:00
|
|
|
fn main() {
|
|
|
|
path := os.args[1]
|
|
|
|
println('V2 $path')
|
2020-01-02 10:30:15 +03:00
|
|
|
table := table.new_table()
|
|
|
|
program := parser.parse_file(path, table)
|
2020-01-02 22:09:15 +03:00
|
|
|
res := gen.cgen([program], table)
|
2019-12-29 10:51:55 +03:00
|
|
|
mut out := os.create('out.c')?
|
2019-12-30 08:16:59 +03:00
|
|
|
out.writeln(cdefs)
|
2019-12-29 10:51:55 +03:00
|
|
|
out.writeln(res)
|
|
|
|
out.close()
|
2019-12-30 08:16:59 +03:00
|
|
|
println('out.c generated')
|
|
|
|
os.system('cc out.c')
|
2019-12-29 10:51:55 +03:00
|
|
|
}
|