From ea3a2f7f05cf2144bb341127d06d9b3779de3394 Mon Sep 17 00:00:00 2001 From: elvis Date: Mon, 27 Oct 2025 14:39:36 +0100 Subject: [PATCH] Parse Positive Structures --- grammar_separated/src/grammar.lalrpop | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/grammar_separated/src/grammar.lalrpop b/grammar_separated/src/grammar.lalrpop index 0d0afde..af48077 100644 --- a/grammar_separated/src/grammar.lalrpop +++ b/grammar_separated/src/grammar.lalrpop @@ -224,6 +224,21 @@ Reaction: reaction::Reaction = { } +pub PositiveReactions: Vec = { + > => s +} + +PositiveReaction: reaction::PositiveReaction = { + #[precedence(level="1")] + "[" "," "]" => + reaction::PositiveReaction::from(r, p), + + #[precedence(level="0")] + "[" "r:" "," "p:" "]" => + reaction::PositiveReaction::from(r, p), +} + + // ----------------------------------------------------------------------------- // ContextParser // ----------------------------------------------------------------------------- @@ -261,6 +276,40 @@ ContextProcess: process::Process = { } }; +pub PositiveContext: process::PositiveProcess = { + > => + process::PositiveProcess::NondeterministicChoice{ + children: t.into_iter().map(Rc::new).collect::>() + } +}; + +PositiveContextProcess: process::PositiveProcess = { + "nill" => process::PositiveProcess::Nill, + + "." => + process::PositiveProcess::EntitySet{ entities: c, next_process: Rc::new(k) }, + + "(" ")" => k, + + "(" > ")" => + process::PositiveProcess::Summation{ + children: k.into_iter().map(Rc::new).collect::>() + }, + + "?" "?" "." => + process::PositiveProcess::Guarded{ reaction: r, next_process: Rc::new(k) }, + + "<" "," ">" "." => + process::PositiveProcess::WaitEntity{ repeat: n, + repeated_process: Rc::new(k1), + next_process: Rc::new(k) }, + + => + process::PositiveProcess::RecursiveIdentifier{ + identifier: translator.encode(identifier) + } +}; + // ----------------------------------------------------------------------------- // EnvironmentParser @@ -275,6 +324,17 @@ Env_term: (IdType, process::Process) = { (translator.encode(identifier), k) }; + +pub PositiveEnvironment: Box = { + > => + Box::new(environment::PositiveEnvironment::from(t)) +}; + +PositiveEnv_term: (IdType, process::PositiveProcess) = { + "=" => + (translator.encode(identifier), k) +}; + // ----------------------------------------------------------------------------- // LabelParser // -----------------------------------------------------------------------------