load multiple morphism base files
This commit is contained in:
parent
88978d9008
commit
1068b8ed45
1 changed files with 31 additions and 29 deletions
60
src/main.rs
60
src/main.rs
|
@ -151,40 +151,42 @@ fn parser(
|
||||||
fn main() {
|
fn main() {
|
||||||
let type_dict = Arc::new(RwLock::new(BimapTypeDict::new()));
|
let type_dict = Arc::new(RwLock::new(BimapTypeDict::new()));
|
||||||
|
|
||||||
let src = std::fs::read_to_string(
|
for mb_path in std::env::args().skip(1) {
|
||||||
std::env::args().nth(1).expect("expected file name")
|
let src = std::fs::read_to_string(
|
||||||
).expect("read");
|
mb_path
|
||||||
|
).expect("read");
|
||||||
|
|
||||||
let result = parser(type_dict.clone()).parse(src.clone());
|
let result = parser(type_dict.clone()).parse(src.clone());
|
||||||
match result {
|
match result {
|
||||||
Ok(morphisms) => {
|
Ok(morphisms) => {
|
||||||
println!("parse ok.");
|
println!("parse ok.");
|
||||||
let mut dict = type_dict.write().unwrap();
|
let mut dict = type_dict.write().unwrap();
|
||||||
|
|
||||||
for m in morphisms {
|
for m in morphisms {
|
||||||
println!("{}\n {}\n---> \n {}\n{}\n\n", m.symbol,
|
println!("{}\n {}\n---> \n {}\n{}\n\n", m.symbol,
|
||||||
m.src_type.clone().sugar(&mut *dict).pretty(&mut *dict, 1),
|
m.src_type.clone().sugar(&mut *dict).pretty(&mut *dict, 1),
|
||||||
m.dst_type.clone().sugar(&mut *dict).pretty(&mut *dict, 1),
|
m.dst_type.clone().sugar(&mut *dict).pretty(&mut *dict, 1),
|
||||||
|
|
||||||
m.expected_c_type_signature(&mut *dict),
|
m.expected_c_type_signature(&mut *dict),
|
||||||
);
|
);
|
||||||
|
|
||||||
m.generate_call(&mut *dict);
|
m.generate_call(&mut *dict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(errs) => {
|
||||||
|
errs.into_iter().for_each(|e| {
|
||||||
|
Report::build(ReportKind::Error, (), e.span().start)
|
||||||
|
.with_message(e.to_string())
|
||||||
|
.with_label(
|
||||||
|
Label::new(e.span())
|
||||||
|
.with_message(e)
|
||||||
|
.with_color(Color::Red),
|
||||||
|
)
|
||||||
|
.finish()
|
||||||
|
.print(Source::from(&src))
|
||||||
|
.unwrap()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Err(errs) => {
|
|
||||||
errs.into_iter().for_each(|e| {
|
|
||||||
Report::build(ReportKind::Error, (), e.span().start)
|
|
||||||
.with_message(e.to_string())
|
|
||||||
.with_label(
|
|
||||||
Label::new(e.span())
|
|
||||||
.with_message(e)
|
|
||||||
.with_color(Color::Red),
|
|
||||||
)
|
|
||||||
.finish()
|
|
||||||
.print(Source::from(&src))
|
|
||||||
.unwrap()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue