summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: bb12399fc0bd71a3dae02d80dbe1779587e18bb2 (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
// 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 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 {
                println!("{:?}", semantic::translate::translate(&program));
            }
        }
        else {
            break;
        }
    }
}