Adding transitions support

This commit is contained in:
elvis
2025-05-21 00:03:36 +02:00
parent 32c2fc2701
commit 4507b0194f
6 changed files with 187 additions and 44 deletions

View File

@ -12,21 +12,28 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// let result = grammar::SetParser::new().parse(&buffer).unwrap();
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();
// -------------------------------------------------------------------------
// 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();
let process1 = rsprocess::structure::RSreaction::from(reactants, inihibitors, products);
// let process1 = rsprocess::structure::RSreaction::from(reactants, inihibitors, products);
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();
// 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();
let process2 = rsprocess::structure::RSreaction::from(reactants, inihibitors, products);
// let process2 = rsprocess::structure::RSreaction::from(reactants, inihibitors, products);
let current_state = grammar::SetParser::new().parse("{b}").unwrap();
// let current_state = grammar::SetParser::new().parse("{b}").unwrap();
println!("{:?}", rsprocess::classical::compute_all(&current_state, vec![&process1, &process2]));
// println!("{:?}", rsprocess::classical::compute_all(&current_state, vec![&process1, &process2]));
// -------------------------------------------------------------------------
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();
println!("{:?}", rsprocess::transitions::unfold(&env, &process));
Ok(())
}