Website Summary Files Commits Branches @commit @diff @stats
path: root / assembler / src / parser / mod.rs
diff options
context:
space:
mode:
Commit9517d3d05e86621b6c4ed58edd7f5821632e0872 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-02-14 08:23:08 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-02-14 08:24:27 +0200
Files2d633e6452e8167bada5db90d061cbdbd8ffcf89 /assembler/src/parser/mod.rs
tonkobali-9517d3d05e86621b6c4ed58edd7f5821632e0872.tar
tonkobali-9517d3d05e86621b6c4ed58edd7f5821632e0872.tar.gz
tonkobali-9517d3d05e86621b6c4ed58edd7f5821632e0872.zip
Parent2cf1097e124c5a0c5836987416b080b6aa4cdd0f (diff)
feat(assembler): Implemented semantic analysis
1 files changed, 25 insertions, 0 deletions
-rw-r--r--assembler/src/parser/mod.rs25
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)]