aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/parser.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/parser.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/parser.rs')
-rw-r--r--lib/xixanta/src/parser.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs
index 13594e7..50f2af1 100644
--- a/lib/xixanta/src/parser.rs
+++ b/lib/xixanta/src/parser.rs
@@ -651,14 +651,19 @@ impl Parser {
// If this is an .if already, then we can quit, otherwise we must
// ensure that the next node is an .if/.elsif and continue the loop.
match node.node_type {
- NodeType::Control(ControlType::If) => {
+ NodeType::Control(ControlType::If)
+ | NodeType::Control(ControlType::IfDef)
+ | NodeType::Control(ControlType::IfNDef) => {
nodes.truncate(nodes.len() - count);
return Ok(());
}
NodeType::Control(ControlType::Elsif) => {
if !matches!(
next.node_type,
- NodeType::Control(ControlType::If) | NodeType::Control(ControlType::Elsif)
+ NodeType::Control(ControlType::If)
+ | NodeType::Control(ControlType::IfDef)
+ | NodeType::Control(ControlType::IfNDef)
+ | NodeType::Control(ControlType::Elsif)
) {
return Err(self.parser_error("expecting an .if statement").into());
}
@@ -666,7 +671,10 @@ impl Parser {
NodeType::Control(ControlType::Else) => {
if !matches!(
next.node_type,
- NodeType::Control(ControlType::If) | NodeType::Control(ControlType::Elsif)
+ NodeType::Control(ControlType::If)
+ | NodeType::Control(ControlType::IfDef)
+ | NodeType::Control(ControlType::IfNDef)
+ | NodeType::Control(ControlType::Elsif)
) {
return Err(self.parser_error("expecting an .if statement").into());
}