read morphism base from file
This commit is contained in:
parent
f0f8adbbbc
commit
e500a24d2a
1 changed files with 6 additions and 24 deletions
30
src/main.rs
30
src/main.rs
|
@ -69,39 +69,21 @@ fn parser(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
|
||||||
|
|
||||||
let src = "
|
|
||||||
morph_digit_as_char_to_uint8 (Radix:ℤ_16)
|
|
||||||
<Digit Radix> ~ Char ~ Ascii ~ Byte
|
|
||||||
--> <Digit Radix> ~ x86.UInt8 ~ Byte
|
|
||||||
@lib/libmorph_posint.so:src/posint.c
|
|
||||||
|
|
||||||
morph_string_as_nullterm_to_length_prefix ()
|
|
||||||
<Seq~<ValueDelim '\\0'> Char ~ Ascii>
|
|
||||||
--> <Seq~<LengthPrefix x86.UInt64> Char ~ Ascii>
|
|
||||||
@lib/libmorph_length-prefix.so:src/length_prefix.c
|
|
||||||
|
|
||||||
morph_string_as_length_prefix_to_nullterm ()
|
|
||||||
<Seq~<LengthPrefix x86.UInt64> Char ~ Ascii>
|
|
||||||
--> <Seq~<ValueDelim '\\0'> Char ~ Ascii>
|
|
||||||
@lib/libmorph_length-prefix.so:src/length_prefix.c
|
|
||||||
";
|
|
||||||
|
|
||||||
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(
|
||||||
|
std::env::args().nth(1).expect("expected file name")
|
||||||
|
).expect("read");
|
||||||
|
|
||||||
let result = parser(type_dict.clone()).parse(src);
|
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", m.symbol,
|
println!("{}\n {}\n---> \n {}\n", m.symbol,
|
||||||
m.src_type.normalize().sugar(&mut *dict).pretty(&mut *dict, 1),
|
m.src_type.sugar(&mut *dict).pretty(&mut *dict, 1),
|
||||||
m.dst_type.normalize().sugar(&mut *dict).pretty(&mut *dict, 1),
|
m.dst_type.sugar(&mut *dict).pretty(&mut *dict, 1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue