summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: f3128a22288be86d589528d972ae1009afa0d050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright ⓒ 2017 David Li.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

pub mod ast;
pub mod semantic;
pub mod taiga;

use std::io::{self, BufRead, Write};

fn main() {
    let stdin = io::stdin();
    let mut handle = stdin.lock();
    loop {
        let mut translate = semantic::translate::Translate::<semantic::frame::Amd64Frame>::new();
        let mut toplevel = semantic::translate::Level::Top;
        let mut level = translate.make_level(&mut toplevel, vec![]);
        let mut input = String::new();
        print!("taiga> ");
        io::stdout().flush().unwrap();
        if let Ok(n) = handle.read_line(&mut input) {
            if n == 0 { break; }
            let program = taiga::parse_Program(&input);
            println!("{:?}", program);
            if let Ok(program) = program {
                let result = semantic::analysis::translate(&mut translate, &mut level, &program);
                println!("{:?}", result);
            }
        }
        else {
            break;
        }
    }
}