Various parser fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user