diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-16 16:13:58 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-16 16:13:58 +0100 |
| commit | 161d7b406b7fba75a2057b8d9e780f521b9bc6bf (patch) | |
| tree | ecc58d0fe36d8a187e40e71fb2eeb1bce13eff3e /lib/xixanta/src/node.rs | |
| parent | 9261588dcaa10aac0a9b8b7a81ff70a621cf1551 (diff) | |
| download | tools.nes-161d7b406b7fba75a2057b8d9e780f521b9bc6bf.tar.gz tools.nes-161d7b406b7fba75a2057b8d9e780f521b9bc6bf.zip | |
Implement .if/.elsif/.else statements
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/node.rs')
| -rw-r--r-- | lib/xixanta/src/node.rs | 19 |
1 files changed, 17 insertions, 2 deletions
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, } } |
