Website Summary Files Commits Branches @commit @diff @stats
path: root / assembler / src / parser / semantic.rs
diff options
context:
space:
mode:
1 files changed, 23 insertions, 0 deletions
-rw-r--r--assembler/src/parser/semantic.rs23
diff --git a/assembler/src/parser/semantic.rs b/assembler/src/parser/semantic.rs
new file mode 100644
index 0000000..47ba201
--- /dev/null
+++ b/assembler/src/parser/semantic.rs
@@ -0,0 +1,23 @@
+use super::{ Address, Program };
+
+impl Program {
+ pub(crate) fn remove_definition_addresses(&mut self) {
+ for instr in &mut self.instructions {
+ for arg in &mut instr.args {
+ if let Address::Definitions(name) = arg {
+ *arg = self.definitions[name].clone();
+ }
+ }
+ }
+ self.definitions.clear();
+ }
+
+ pub(crate) fn analyze(&self) {
+ for instr in &self.instructions {
+ let result = instr.check_args();
+ if result.is_err() {
+ panic!("Instruction '{}' error: {:?}", instr.name, result.err().unwrap());
+ }
+ }
+ }
+}