From 1f8a6becc7cdca285333d51b4548373974df7dd3 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sat, 4 Jan 2025 17:12:11 +0100 Subject: parser: Implement block bodies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are bodies which are the right node of some proc controls. This way the parser comes back to sanity for statements like .macro and the likes, and behaves more like a usual parser. This was not done in the past because I thought things could have been simpler this way, but it ended up making the assembler way more complicated that it needed to. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/assembler.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/xixanta/src/assembler.rs') diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index e9d2025..f2ca35b 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -123,16 +123,18 @@ impl Assembler { return Err(errors.iter().map(|e| Error::Parse(e.clone())).collect()); } + let nodes = parser.nodes(); + // Build the context by iterating over the parsed nodes and checking // where scopes start/end, evaluating values for variables, labels, etc. - self.eval_context(&parser.nodes)?; + self.eval_context(&nodes)?; // Convert the relevant nodes into binary bundles which can be used by // the caller. This is done for most nodes, even if some of them will // have to be marked as pending, since they depend on knowing the exact // size for a given segment. self.stage = Stage::Bundling; - self.bundle(&parser.nodes)?; + self.bundle(&nodes)?; // Now we know how much each segment spans, and we can resolve (crunch) // the nodes marked as pending. -- cgit v1.2.3