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