diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-16 16:33:10 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-16 16:33:10 +0100 |
| commit | 2455e2bbcfb4372b13a351471a49a585ceb1597c (patch) | |
| tree | b751542e846f4eb075163c5580d8b4d85295a630 /lib/xixanta/src/parser.rs | |
| parent | a3a630dfee207c111213d2cad85ceb983df7625a (diff) | |
| download | tools.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.rs | 14 |
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()); } |
