// 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::cell::RefCell; use std::io::{self, BufRead, Write}; use std::rc::Rc; fn main() { let stdin = io::stdin(); let mut handle = stdin.lock(); loop { let mut translate = semantic::translate::Translate::::new(); let toplevel = Rc::new(RefCell::new(semantic::translate::Level::Top)); let level = translate.make_level(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, level, &program); println!("{:?}", result); } } else { break; } } }