]>
Witch of Git - ivy/blob - src/main.rs
1 use std
::io
::{self, Read
};
2 use ivy
::{parse
, BUILTINS
, ast
::Ast
, trans
::{self, translate
}};
4 fn main() -> io
::Result
<()> {
5 let stdin
= std
::io
::stdin();
6 let mut text
= String
::new();
7 stdin
.lock().read_to_string(&mut text
)?
;
8 let sexp
= match parse(&text
) {
11 println
!("{:?}", err
);
12 std
::process
::exit(1);
15 let (ast
, mut builtins
) = match Ast
::parse(BUILTINS
, &sexp
) {
19 std
::process
::exit(1);
22 let code
= match translate(&ast
) {
26 std
::process
::exit(1);
29 builtins
.retain(|_
, v
| code
.globals
.contains(&v
.global_number().unwrap
()));
30 let stdout
= std
::io
::stdout();
31 trans
::x64
::write_compile(&builtins
, &mut stdout
.lock(), &code
)?
;