mod builtin_cells; mod frontend; mod literals; mod parser; mod rtlil; use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; use structopt::StructOpt; #[derive(Debug, StructOpt)] #[structopt(name = "example", about = "An example of StructOpt usage.")] struct Opt { /// Input file #[structopt(parse(from_os_str))] input: PathBuf, } fn main() { let opt = Opt::from_args(); let mut infile = File::open(opt.input).expect("could not open file"); let mut input = String::new(); infile .read_to_string(&mut input) .expect("error reading file"); let input: &str = input.as_str(); let input = parser::Span::new(input); let parsed = parser::parse(input); match parsed { Err(nom::Err::Error(_err) | nom::Err::Failure(_err)) => { // TODO: get this working again // print!("{}", convert_error(input, err)) } Err(_) => (), Ok(res) => { println!("{:#?}", res); let lowered = crate::frontend::lower_module(res.1); match lowered { Ok(res) => println!("{}", res), Err(err) => println!("{:#?}", err), } } } }