From e71a73d0875c416507a3207bdec6fee145a79f68 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 6 Oct 2026 17:33:16 +0200 Subject: Don't error out on conditional .include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hard requirement that an .include statement cannot be inside of another block was, in the end, a bit short-sighted. Imagine the following block: .ifdef DEBUG .include "debug.s" .endif This is perfectly sound-looking code, and it should not be punished as the developer is doing something that is not bending the assembler in weird ways. Hence, just nuke this check. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/parser.rs | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'lib/xixanta/src/parser.rs') diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs index a71c6f6..07d028c 100644 --- a/lib/xixanta/src/parser.rs +++ b/lib/xixanta/src/parser.rs @@ -1040,33 +1040,6 @@ impl Parser { &node.node_type, NodeType::Control(ControlType::IncludeSource) ) { - // Validate that it's a top layer statement. - if self.nodes.len() > 1 { - // This is not a top layer statement! Usually it would be a - // cause for trouble, but we actually allow this in case this is - // all just a bunch of `.scope` statements surrounding - // things. NOTE: the iteration has to go over all top nodes - // except the last one which is the current one. - let nodes = &self.nodes[..self.nodes.len() - 1]; - if nodes.iter().any(|n| { - !matches!( - n.last().unwrap().node_type, - NodeType::Control(ControlType::StartScope) - ) - }) { - // There is something else besides a '.scope' statement, - // this is just asking for trouble... - return Err(Error { - line: node.value.line, - global: false, - message: ".include statement cannot be inside of a code block".to_string(), - expanded_from: vec![], - source: self.sources[self.current_source].clone(), - } - .into()); - } - } - // Before including all the nodes from the referenced file, add the // .include statement. This should be ignored by the assembler, but // maybe other tools want to make use of it. -- cgit v1.2.3