From 161d7b406b7fba75a2057b8d9e780f521b9bc6bf Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 16 Jan 2025 16:13:58 +0100 Subject: Implement .if/.elsif/.else statements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/node.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lib/xixanta/src/node.rs') diff --git a/lib/xixanta/src/node.rs b/lib/xixanta/src/node.rs index a31c578..ae79f1e 100644 --- a/lib/xixanta/src/node.rs +++ b/lib/xixanta/src/node.rs @@ -143,6 +143,10 @@ pub enum ControlType { IncludeSource, ReserveMemory, Asciiz, + If, + Elsif, + Else, + EndIf, } impl fmt::Display for ControlType { @@ -166,6 +170,10 @@ impl fmt::Display for ControlType { ControlType::IncludeSource => write!(f, ".include"), ControlType::ReserveMemory => write!(f, ".res"), ControlType::Asciiz => write!(f, ".asciiz"), + ControlType::If => write!(f, ".if"), + ControlType::Elsif => write!(f, ".elsif"), + ControlType::Else => write!(f, ".else"), + ControlType::EndIf => write!(f, ".endif"), } } } @@ -324,6 +332,9 @@ impl NodeType { NodeType::Control(ControlType::StartRepeat) => { Some(NodeType::Control(ControlType::EndRepeat)) } + NodeType::Control(ControlType::If) => Some(NodeType::Control(ControlType::EndIf)), + NodeType::Control(ControlType::Elsif) => Some(NodeType::Control(ControlType::EndIf)), + NodeType::Control(ControlType::Else) => Some(NodeType::Control(ControlType::EndIf)), _ => None, } } @@ -389,11 +400,15 @@ impl PNode { NodeType::Control(ControlType::StartMacro) | NodeType::Control(ControlType::StartProc) | NodeType::Control(ControlType::StartScope) - | NodeType::Control(ControlType::StartRepeat) => NodeBodyType::Starts, + | NodeType::Control(ControlType::StartRepeat) + | NodeType::Control(ControlType::If) + | NodeType::Control(ControlType::Elsif) + | NodeType::Control(ControlType::Else) => NodeBodyType::Starts, NodeType::Control(ControlType::EndMacro) | NodeType::Control(ControlType::EndProc) | NodeType::Control(ControlType::EndScope) - | NodeType::Control(ControlType::EndRepeat) => NodeBodyType::Ends, + | NodeType::Control(ControlType::EndRepeat) + | NodeType::Control(ControlType::EndIf) => NodeBodyType::Ends, _ => NodeBodyType::None, } } -- cgit v1.2.3