From 9517d3d05e86621b6c4ed58edd7f5821632e0872 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 14 Feb 2025 08:23:08 +0200 Subject: feat(assembler): Implemented semantic analysis --- assembler/src/parser/mod.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'assembler/src/parser/mod.rs') diff --git a/assembler/src/parser/mod.rs b/assembler/src/parser/mod.rs index 79b8835..d43b9c5 100644 --- a/assembler/src/parser/mod.rs +++ b/assembler/src/parser/mod.rs @@ -1,5 +1,6 @@ mod code_gen; mod syntax; +mod semantic; mod instruction; use std::{ @@ -53,6 +54,30 @@ impl Address { *self = Address::None; val } + + fn is_memory(&self) -> bool { + if let Address::Memory(_) = &self { true } else { false } + } + + fn is_constant(&self) -> bool { + if let Address::Constants(_) = &self { true } else { false } + } + + fn is_instruction(&self) -> bool { + if let Address::Instruction(_) = &self { true } else { false } + } + + fn is_definition(&self) -> bool { + if let Address::Definitions(_) = &self { true } else { false } + } + + fn is_none(&self) -> bool { + if let Address::None = &self { true } else { false } + } + + fn is_location(&self) -> bool { + self.is_memory() || self.is_instruction() + } } #[derive(Debug, Default, Clone)] -- cgit v1.3.1-26-gb76a