Files
ReactionSystems/src/main.rs

110 lines
4.4 KiB
Rust
Raw Normal View History

2025-05-14 11:42:19 +02:00
mod rsprocess;
use lalrpop_util::lalrpop_mod;
2025-05-19 00:10:23 +02:00
// use std::io;
2025-05-14 11:42:19 +02:00
fn main() -> Result<(), Box<dyn std::error::Error>> {
lalrpop_mod!(grammar, "/rsprocess/grammar.rs");
2025-05-19 00:10:23 +02:00
// let mut buffer = String::new();
// let i = io::stdin();
// i.read_line(&mut buffer).expect("Can't read stdin");
2025-05-14 11:42:19 +02:00
2025-05-19 00:10:23 +02:00
// let result = grammar::SetParser::new().parse(&buffer).unwrap();
2025-05-21 00:03:36 +02:00
// -------------------------------------------------------------------------
// let reactants = grammar::SetParser::new().parse("{a}").unwrap();
// let inihibitors = grammar::SetParser::new().parse("{c}").unwrap();
// let products = grammar::SetParser::new().parse("{a,c}").unwrap();
2025-05-19 00:10:23 +02:00
2025-05-21 00:03:36 +02:00
// let process1 = rsprocess::structure::RSreaction::from(reactants, inihibitors, products);
2025-05-19 00:10:23 +02:00
2025-05-21 00:03:36 +02:00
// let reactants = grammar::SetParser::new().parse("{b}").unwrap();
// let inihibitors = grammar::SetParser::new().parse("{c}").unwrap();
// let products = grammar::SetParser::new().parse("{b,c}").unwrap();
2025-05-19 00:10:23 +02:00
2025-05-21 00:03:36 +02:00
// let process2 = rsprocess::structure::RSreaction::from(reactants, inihibitors, products);
2025-05-19 00:10:23 +02:00
2025-05-21 00:03:36 +02:00
// let current_state = grammar::SetParser::new().parse("{b}").unwrap();
2025-05-19 00:10:23 +02:00
2025-05-21 00:03:36 +02:00
// println!("{:?}", rsprocess::classical::compute_all(&current_state, vec![&process1, &process2]));
2025-05-14 11:42:19 +02:00
2025-05-21 00:03:36 +02:00
// -------------------------------------------------------------------------
2025-06-12 16:23:39 +02:00
// let env = grammar::EnvironmentParser::new().parse("[x = {a}.{b}.x , y = ({a,c}.y + {b,c}.y)]").unwrap();
// let process = grammar::ContextParser::new().parse("[({a}.nil + x + y)]").unwrap();
2025-05-21 00:03:36 +02:00
2025-06-12 16:23:39 +02:00
// println!("{:?}", rsprocess::transitions::unfold(&env, &process));
// println!("--------------------");
// println!("{:?}", env);
// -------------------------------------------------------------------------
// allTransitions(sys([],[a,b],[],[react([a],[c],[a]),react([b],[d],[b])]) , Moves).
// let env = grammar::EnvironmentParser::new().parse("[]").unwrap();
// let process = grammar::ContextParser::new().parse("[]").unwrap();
// let sys = rsprocess::structure::RSsystem::from(*env,
// rsprocess::structure::RSset::from(vec!["a", "b"]),
// *process,
// vec![
// rsprocess::structure::RSreaction::from(
// rsprocess::structure::RSset::from(vec!["a"]),
// rsprocess::structure::RSset::from(vec!["c"]),
// rsprocess::structure::RSset::from(vec!["a"])
// ),
// rsprocess::structure::RSreaction::from(
// rsprocess::structure::RSset::from(vec!["b"]),
// rsprocess::structure::RSset::from(vec!["d"]),
// rsprocess::structure::RSset::from(vec!["b"])
// )
// ]);
// println!("all_transitions: {:?}", rsprocess::transitions::all_transitions(&sys));
// -------------------------------------------------------------------------
// parse_ctx("[({a}.nil + {b}.nil)]",Ks) , allTransitions(sys([],[],Ks,[react([a],[c],[a]),react([b],[d],[b])]),Moves).
let env = grammar::EnvironmentParser::new().parse("[]").unwrap();
let process = grammar::ContextParser::new().parse("[({a}.nil + {b}.nil)]").unwrap();
let sys = rsprocess::structure::RSsystem::from(*env,
rsprocess::structure::RSset::from(vec![]),
*process,
vec![
rsprocess::structure::RSreaction::from(
rsprocess::structure::RSset::from(vec!["a"]),
rsprocess::structure::RSset::from(vec!["c"]),
rsprocess::structure::RSset::from(vec!["a"])
),
rsprocess::structure::RSreaction::from(
rsprocess::structure::RSset::from(vec!["b"]),
rsprocess::structure::RSset::from(vec!["d"]),
rsprocess::structure::RSset::from(vec!["b"])
)
]);
println!("all_transitions: {:?}", rsprocess::transitions::all_transitions(&sys));
// -------------------------------------------------------------------------
// use std::rc::Rc;
// let mut a = rsprocess::structure::RSChoices::from(vec![
// (Rc::new(rsprocess::structure::RSset::from(vec!["a"])),
// Rc::new(rsprocess::structure::RSprocess::Nill)),
// ]);
// let b = rsprocess::structure::RSChoices::from(vec![
// (Rc::new(rsprocess::structure::RSset::from(vec!["b"])),
// Rc::new(rsprocess::structure::RSprocess::Nill)),
// ]);
// a.shuffle(b);
// println!("shuffle: {:?}", a);
println!("--------------------");
2025-05-14 11:42:19 +02:00
Ok(())
}