Simple process reaction
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
use std::str::FromStr;
|
||||
use lalrpop_util::ParseError;
|
||||
use crate::rsprocess::{RSset, RSprocess, RSenvironment, RSassert, RSassertOp, RSBHML};
|
||||
use crate::rsprocess::structure::{RSset, RSprocess, RSenvironment, RSassert, RSassertOp, RSBHML};
|
||||
|
||||
grammar;
|
||||
|
||||
@ -29,28 +29,35 @@ pub Set: RSset<'input> = {
|
||||
<s: Set_of_entities> => s
|
||||
};
|
||||
|
||||
// ----- ContextParser -----
|
||||
pub Context: Box<RSprocess<'input>> = {
|
||||
"[" "]" => Box::new(RSprocess::Nill),
|
||||
"[" <t: CTX_process> "]" => Box::new(t),
|
||||
"[" <t: Separeted<CTX_process, ",">> "]" => Box::new(RSprocess::NondeterministicChoice{children: t})
|
||||
};
|
||||
|
||||
CTX_process: RSprocess<'input> = {
|
||||
<c: Set_of_entities> "." <k: CTX_process> => RSprocess::EntitySet{entities: c, next_process: Box::new(k)},
|
||||
"(" <k: CTX_process> ")" => k,
|
||||
"(" <k: Separeted<CTX_process, "+">> ")" => RSprocess::Summation{children: k},
|
||||
"<" <n: Num> <k1: CTX_process> ">" "." <k: CTX_process> => RSprocess::WaitEntity{repeat: n, repeated_process: Box::new(k1), next_process: Box::new(k)},
|
||||
"nil" => RSprocess::Nill,
|
||||
<identifier: Literal> => RSprocess::ConstantIdentifier{identifier: identifier}
|
||||
};
|
||||
|
||||
Set_of_entities: RSset<'input> = {
|
||||
"{" "}" => RSset::from(vec![]),
|
||||
"{" <t: Literal> "}" => RSset::from(vec![t]),
|
||||
"{" <t: Separeted<Literal, ",">> "}" => RSset::from(t)
|
||||
};
|
||||
|
||||
// ----- ContextParser -----
|
||||
pub Context: Box<RSprocess<'input>> = {
|
||||
"[" "]" => Box::new(RSprocess::Nill),
|
||||
"[" <t: CTX_process> "]" => Box::new(t),
|
||||
"[" <t: Separeted<CTX_process, ",">> "]" =>
|
||||
Box::new(RSprocess::NondeterministicChoice{ children: t })
|
||||
};
|
||||
|
||||
CTX_process: RSprocess<'input> = {
|
||||
<c: Set_of_entities> "." <k: CTX_process> =>
|
||||
RSprocess::EntitySet{ entities: c, next_process: Box::new(k) },
|
||||
"(" <k: CTX_process> ")" => k,
|
||||
"(" <k: Separeted<CTX_process, "+">> ")" =>
|
||||
RSprocess::Summation{ children: k },
|
||||
"<" <n: Num> <k1: CTX_process> ">" "." <k: CTX_process> =>
|
||||
RSprocess::WaitEntity{ repeat: n,
|
||||
repeated_process: Box::new(k1),
|
||||
next_process: Box::new(k)},
|
||||
"nil" => RSprocess::Nill,
|
||||
<identifier: Literal> =>
|
||||
RSprocess::ConstantIdentifier{ identifier: identifier }
|
||||
};
|
||||
|
||||
// ----- EnvironmentParser -----
|
||||
pub Environment: Box<RSenvironment<'input>> = {
|
||||
"[" "]" => Box::new(RSenvironment::new()),
|
||||
@ -68,7 +75,8 @@ pub Assert: Box<RSassert<'input>> = {
|
||||
|
||||
Formula_Assert: RSassert<'input> = {
|
||||
"-" <f: Formula_Assert> => RSassert::Not(Box::new(f)),
|
||||
"(" <f1: Formula_Assert> "^" <f2: Formula_Assert> ")" => RSassert::Xor(Box::new(f1), Box::new(f2)),
|
||||
"(" <f1: Formula_Assert> "^" <f2: Formula_Assert> ")" =>
|
||||
RSassert::Xor(Box::new(f1), Box::new(f2)),
|
||||
"(" <f: Separeted<Formula_Assert, "\\/">> ")" => RSassert::Or(f),
|
||||
"(" <f: Separeted<Formula_Assert, "/\\">> ")" => RSassert::And(f),
|
||||
<c: Set_of_entities> "inW" => RSassert::Sub(c, RSassertOp::InW),
|
||||
@ -91,6 +99,8 @@ Formula_BHML: RSBHML<'input> = {
|
||||
"false" => RSBHML::False,
|
||||
"(" <g: Separeted<Formula_BHML, "\\/">> ")" => RSBHML::Or(g),
|
||||
"(" <g: Separeted<Formula_BHML, "/\\">> ")" => RSBHML::And(g),
|
||||
"<" <f: Formula_Assert> ">" <g: Formula_BHML> => RSBHML::Diamond(Box::new(f), Box::new(g)),
|
||||
"[" <f: Formula_Assert> "]" <g: Formula_BHML> => RSBHML::Box(Box::new(f), Box::new(g)),
|
||||
"<" <f: Formula_Assert> ">" <g: Formula_BHML> =>
|
||||
RSBHML::Diamond(Box::new(f), Box::new(g)),
|
||||
"[" <f: Formula_Assert> "]" <g: Formula_BHML> =>
|
||||
RSBHML::Box(Box::new(f), Box::new(g)),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user