Various parser fixes

This commit is contained in:
2025-11-23 00:10:48 -07:00
parent c3adcf57f5
commit 92c1047ef8
2 changed files with 22 additions and 5 deletions

View File

@@ -731,7 +731,10 @@ impl Parser {
match invocation.name.as_str() { match invocation.name.as_str() {
// system calls // 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" => { "sleep" => {
check_length(self, &invocation.arguments, 1)?; check_length(self, &invocation.arguments, 1)?;
let mut arg = invocation.arguments.iter(); let mut arg = invocation.arguments.iter();
@@ -752,7 +755,7 @@ impl Parser {
Ok(SysCall::System(sys_call::System::LoadFromDevice( Ok(SysCall::System(sys_call::System::LoadFromDevice(
device, device,
variable.clone(), LiteralOrVariable::Variable(variable.clone()),
))) )))
} }
"setOnDevice" => { "setOnDevice" => {
@@ -772,7 +775,9 @@ impl Parser {
let variable = literal_or_variable!(args.next()); let variable = literal_or_variable!(args.next());
Ok(SysCall::System(sys_call::System::SetOnDevice( Ok(SysCall::System(sys_call::System::SetOnDevice(
device, logic_type, variable, device,
Literal::String(logic_type),
variable,
))) )))
} }
// math calls // math calls

View File

@@ -1,3 +1,5 @@
use crate::tree_node::Literal;
use super::LiteralOrVariable; use super::LiteralOrVariable;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
@@ -111,13 +113,20 @@ pub enum System {
/// ## Examples /// ## Examples
/// `l r0 d0 Setting` /// `l r0 d0 Setting`
/// `l r1 d5 Pressure` /// `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. /// Represents a function which stores a setting into a specific device.
/// ## In Game /// ## In Game
/// `s d? logicType r?` /// `s d? logicType r?`
/// ## Example /// ## Example
/// `s d0 Setting r0` /// `s d0 Setting r0`
SetOnDevice(LiteralOrVariable, String, LiteralOrVariable), SetOnDevice(LiteralOrVariable, Literal, LiteralOrVariable),
} }
impl std::fmt::Display for System { impl std::fmt::Display for System {
@@ -127,6 +136,9 @@ impl std::fmt::Display for System {
System::Sleep(a) => write!(f, "sleep({})", a), System::Sleep(a) => write!(f, "sleep({})", a),
System::Hash(a) => write!(f, "HASH({})", a), System::Hash(a) => write!(f, "HASH({})", a),
System::LoadFromDevice(a, b) => write!(f, "loadFromDevice({}, {})", a, b), 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), System::SetOnDevice(a, b, c) => write!(f, "setOnDevice({}, {}, {})", a, b, c),
} }
} }