From 92c1047ef843a783adfc91aa287ac6d8c1c372dc Mon Sep 17 00:00:00 2001 From: Devin Bidwell Date: Sun, 23 Nov 2025 00:10:48 -0700 Subject: [PATCH] Various parser fixes --- libs/parser/src/lib.rs | 11 ++++++++--- libs/parser/src/sys_call.rs | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libs/parser/src/lib.rs b/libs/parser/src/lib.rs index f3a356e..63b5b32 100644 --- a/libs/parser/src/lib.rs +++ b/libs/parser/src/lib.rs @@ -731,7 +731,10 @@ impl Parser { match invocation.name.as_str() { // system calls - "yield" => Ok(SysCall::System(sys_call::System::Yield)), + "yield" => { + check_length(self, &invocation.arguments, 0)?; + Ok(SysCall::System(sys_call::System::Yield)) + } "sleep" => { check_length(self, &invocation.arguments, 1)?; let mut arg = invocation.arguments.iter(); @@ -752,7 +755,7 @@ impl Parser { Ok(SysCall::System(sys_call::System::LoadFromDevice( device, - variable.clone(), + LiteralOrVariable::Variable(variable.clone()), ))) } "setOnDevice" => { @@ -772,7 +775,9 @@ impl Parser { let variable = literal_or_variable!(args.next()); Ok(SysCall::System(sys_call::System::SetOnDevice( - device, logic_type, variable, + device, + Literal::String(logic_type), + variable, ))) } // math calls diff --git a/libs/parser/src/sys_call.rs b/libs/parser/src/sys_call.rs index eec5ade..38a40ae 100644 --- a/libs/parser/src/sys_call.rs +++ b/libs/parser/src/sys_call.rs @@ -1,3 +1,5 @@ +use crate::tree_node::Literal; + use super::LiteralOrVariable; #[derive(Debug, PartialEq, Eq)] @@ -111,13 +113,20 @@ pub enum System { /// ## Examples /// `l r0 d0 Setting` /// `l r1 d5 Pressure` - LoadFromDevice(LiteralOrVariable, String), + LoadFromDevice(LiteralOrVariable, LiteralOrVariable), + /// Function which gets a LogicType from all connected network devices that match + /// the provided device hash and name, aggregating them via a batchMode + /// ## In Game + /// lbn r? deviceHash nameHash logicType batchMode + /// ## Examples + /// lbn r0 HASH("StructureWallLight") HASH("wallLight") On Minimum + LoadBatchNamed(LiteralOrVariable, Literal, Literal, Literal), /// Represents a function which stores a setting into a specific device. /// ## In Game /// `s d? logicType r?` /// ## Example /// `s d0 Setting r0` - SetOnDevice(LiteralOrVariable, String, LiteralOrVariable), + SetOnDevice(LiteralOrVariable, Literal, LiteralOrVariable), } impl std::fmt::Display for System { @@ -127,6 +136,9 @@ impl std::fmt::Display for System { System::Sleep(a) => write!(f, "sleep({})", a), System::Hash(a) => write!(f, "HASH({})", a), System::LoadFromDevice(a, b) => write!(f, "loadFromDevice({}, {})", a, b), + System::LoadBatchNamed(a, b, c, d) => { + write!(f, "loadBatchNamed({}, {}, {}, {})", a, b, c, d) + } System::SetOnDevice(a, b, c) => write!(f, "setOnDevice({}, {}, {})", a, b, c), } }