use std::sync::Arc;
use meta_language::{LanguageParser, LinkNetwork, ParseConfiguration, ParserRegistry};
#[derive(Debug)]
struct ShoutParser;
impl LanguageParser for ShoutParser {
fn parse_source(
&self,
text: &str,
language: &str,
configuration: ParseConfiguration,
) -> LinkNetwork {
LinkNetwork::parse_lossless_text(&text.to_uppercase(), language, configuration)
}
}
fn main() {
let configuration = ParseConfiguration::default();
let registry = ParserRegistry::new().with_parser("shout", Arc::new(ShoutParser));
let shouted = registry.parse("hello world", "shout", configuration);
println!("shout -> {:?}", shouted.reconstruct_text());
let lino = registry.parse("(alpha (beta))", "lino", configuration);
println!("lino -> {:?}", lino.reconstruct_text());
let via_network = LinkNetwork::parse_with_registry(®istry, "again", "shout", configuration);
println!("entry -> {:?}", via_network.reconstruct_text());
}