aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/node.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-16 16:33:10 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-16 16:33:10 +0100
commit2455e2bbcfb4372b13a351471a49a585ceb1597c (patch)
treeb751542e846f4eb075163c5580d8b4d85295a630 /lib/xixanta/src/node.rs
parenta3a630dfee207c111213d2cad85ceb983df7625a (diff)
downloadtools.nes-2455e2bbcfb4372b13a351471a49a585ceb1597c.tar.gz
tools.nes-2455e2bbcfb4372b13a351471a49a585ceb1597c.zip
Implement .ifdef/.ifndef statements
They are just synonyms for ".if .defined" and ".if !.defined" respectively. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/node.rs')
-rw-r--r--lib/xixanta/src/node.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/xixanta/src/node.rs b/lib/xixanta/src/node.rs
index f1eb558..243b478 100644
--- a/lib/xixanta/src/node.rs
+++ b/lib/xixanta/src/node.rs
@@ -144,6 +144,8 @@ pub enum ControlType {
ReserveMemory,
Asciiz,
If,
+ IfDef,
+ IfNDef,
Elsif,
Else,
EndIf,
@@ -172,6 +174,8 @@ impl fmt::Display for ControlType {
ControlType::ReserveMemory => write!(f, ".res"),
ControlType::Asciiz => write!(f, ".asciiz"),
ControlType::If => write!(f, ".if"),
+ ControlType::IfDef => write!(f, ".ifdef"),
+ ControlType::IfNDef => write!(f, ".ifndef"),
ControlType::Elsif => write!(f, ".elsif"),
ControlType::Else => write!(f, ".else"),
ControlType::EndIf => write!(f, ".endif"),
@@ -192,7 +196,14 @@ impl ControlType {
pub fn has_body(&self) -> bool {
matches!(
self,
- ControlType::StartMacro | Self::StartProc | Self::StartScope
+ ControlType::StartMacro
+ | Self::StartProc
+ | Self::StartScope
+ | Self::If
+ | Self::Elsif
+ | Self::Else
+ | Self::IfDef
+ | Self::IfNDef
)
}
}
@@ -335,6 +346,8 @@ impl NodeType {
Some(NodeType::Control(ControlType::EndRepeat))
}
NodeType::Control(ControlType::If) => Some(NodeType::Control(ControlType::EndIf)),
+ NodeType::Control(ControlType::IfDef) => Some(NodeType::Control(ControlType::EndIf)),
+ NodeType::Control(ControlType::IfNDef) => Some(NodeType::Control(ControlType::EndIf)),
NodeType::Control(ControlType::Elsif) => Some(NodeType::Control(ControlType::EndIf)),
NodeType::Control(ControlType::Else) => Some(NodeType::Control(ControlType::EndIf)),
_ => None,
@@ -404,6 +417,8 @@ impl PNode {
| NodeType::Control(ControlType::StartScope)
| NodeType::Control(ControlType::StartRepeat)
| NodeType::Control(ControlType::If)
+ | NodeType::Control(ControlType::IfDef)
+ | NodeType::Control(ControlType::IfNDef)
| NodeType::Control(ControlType::Elsif)
| NodeType::Control(ControlType::Else) => NodeBodyType::Starts,
NodeType::Control(ControlType::EndMacro)