diff --git a/morphisms/digit.morphism-base b/morphisms/digit.morphism-base index 0abff91..54b9d9f 100644 --- a/morphisms/digit.morphism-base +++ b/morphisms/digit.morphism-base @@ -1,3 +1,6 @@ +``` +``` + morph_digit_as_char_to_uint8 (Radix:ℤ) <Digit Radix> ~ Char ~ Ascii ~ x86.UInt8 --> <Digit Radix> ~ x86.UInt8 diff --git a/morphisms/length_prefix.morphism-base b/morphisms/length_prefix.morphism-base index 810f4ce..f8b48aa 100644 --- a/morphisms/length_prefix.morphism-base +++ b/morphisms/length_prefix.morphism-base @@ -1,3 +1,7 @@ +``` +#include <array/length-prefix.h> +``` + morph_array_as_valterm_to_lenpfx (Terminator:x86.UInt8) <Seq~<ValueTerminated Terminator> x86.UInt8> --> <Seq~<LengthPrefix x86.UInt64> x86.UInt8> diff --git a/morphisms/posint.morphism-base b/morphisms/posint.morphism-base index 8300e64..d8838e0 100644 --- a/morphisms/posint.morphism-base +++ b/morphisms/posint.morphism-base @@ -1,3 +1,6 @@ +``` +#include <array/length-prefix.h> +``` morph_nat_as_u64_to_pos () ℕ diff --git a/src/main.rs b/src/main.rs index 852d1ad..13e5516 100644 --- a/src/main.rs +++ b/src/main.rs @@ -335,10 +335,19 @@ impl Morphism for LdmcMorphism { */ fn parser( type_dict: Arc<RwLock< BimapTypeDict >> -) -> impl Parser<char, Vec<LdmcPrimCMorphism>, Error = Simple<char>> { +) -> impl Parser<char, (String, Vec<LdmcPrimCMorphism>), Error = Simple<char>> { + + just("```") + .then(take_until(just("```"))) + .map( + move |(a, (b, c))| { + b.iter().collect() + } + ) // morph name - ident().padded() + .then( + ident().padded() // type args .then( @@ -383,6 +392,8 @@ fn parser( } }) .separated_by(text::newline()) + + ) } fn main() { @@ -401,8 +412,9 @@ fn main() { let src = std::fs::read_to_string(mb_path.clone()).expect("read"); let result = parser(type_dict.clone()).parse(src.clone()); match result { - Ok(morphisms) => { + Ok((includes, morphisms)) => { eprintln!("[{}] parse ok.", mb_path.bright_yellow()); + println!("{}", includes); for m in morphisms { morphism_base.add_morphism(LdmcMorphism::Primitive(m)); } @@ -444,7 +456,6 @@ fn main() { #include <string.h> #include <stdint.h> #include <stdbool.h> -#include <array/length-prefix.h> "#); let mut existing_instantiations = Vec::new();