futilehdl/src/main.rs

38 lines
996 B
Rust
Raw Normal View History

2021-12-30 19:46:28 +00:00
mod literals;
2022-01-01 21:43:38 +00:00
mod parser;
mod rtlil;
2021-12-30 19:46:28 +00:00
2022-01-04 16:28:43 +00:00
use nom::error::convert_error;
2022-01-04 16:24:21 +00:00
use std::path::PathBuf;
use std::fs::File;
use std::io::prelude::*;
2022-01-04 00:38:35 +00:00
use structopt::StructOpt;
2021-12-30 19:46:28 +00:00
2022-01-04 16:24:21 +00:00
#[derive(Debug, StructOpt)]
#[structopt(name = "example", about = "An example of StructOpt usage.")]
struct Opt {
/// Input file
#[structopt(parse(from_os_str))]
input: PathBuf,
}
2021-12-30 19:46:28 +00:00
fn main() {
2022-01-04 16:24:21 +00:00
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 parsed = parser::parse(&input);
2021-12-30 19:46:28 +00:00
match parsed {
Err(nom::Err::Error(err) | nom::Err::Failure(err)) => {
print!("{}", convert_error(input, err))
}
Err(_) => (),
2022-01-01 21:43:38 +00:00
Ok(res) => {
println!("{:#?}", res);
let lowered = crate::rtlil::lower_module(res.1);
println!("{}", lowered);
}
2021-12-30 19:46:28 +00:00
}
}