summaryrefslogtreecommitdiff
path: root/src/environment.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2025-02-14 09:34:48 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2025-02-14 09:34:48 +1300
commite39505931b05be321ee2b04c41a9739f00c19208 (patch)
tree529a4162ed2d34a7c283a928136808bd20750563 /src/environment.rs
parent1995f8a8f2cb5ea810afc173fe8dfa2f5355f684 (diff)
downloadtorque-asm-e39505931b05be321ee2b04c41a9739f00c19208.zip
Implement semantic parsing
Diffstat (limited to 'src/environment.rs')
-rw-r--r--src/environment.rs39
1 files changed, 16 insertions, 23 deletions
diff --git a/src/environment.rs b/src/environment.rs
index d88e1b5..2bb3f5b 100644
--- a/src/environment.rs
+++ b/src/environment.rs
@@ -1,4 +1,5 @@
use crate::*;
+use semantic::*;
use std::collections::HashMap;
@@ -32,32 +33,24 @@ pub struct Scope {
}
impl Scope {
- pub fn get_integer(&self, name: &str, environment: &Environment) -> Result<usize, ()> {
- use IntegerDefinition as IntDef;
- if let Some(definition) = self.definitions.get(name) {
- if let Definition::Integer(integer) = definition {
- match integer {
- IntDef::Literal(value) => return Ok(*value),
- IntDef::ConstantExpression(expr) => match expr.evaluate(environment) {
- Ok(_) | Err(_) => todo!(),
- },
- };
- }
- }
- return Err(());
+ pub fn get_integer(&self, _name: &str, _environment: &Environment) -> Result<usize, ()> {
+ todo!()
+ // use semantic::IntegerDefinition as IntDef;
+
+ // if let Some(Definition { variant, ..}) = self.definitions.get(name) {
+ // if let IntegerDefinition::Integer(integer) = definition {
+ // match integer {
+ // IntDef::Literal(value) => return Ok(*value),
+ // IntDef::ConstantExpression(expr) => match expr.evaluate(environment) {
+ // Ok(_) | Err(_) => todo!(),
+ // },
+ // };
+ // }
+ // }
+ // return Err(());
}
pub fn get_block(&self, _name: &str, _environment: &Environment) -> Result<usize, ()> {
todo!()
}
}
-
-pub enum Definition {
- Integer(IntegerDefinition),
- Block,
-}
-
-pub enum IntegerDefinition {
- Literal(usize),
- ConstantExpression(ConstantExpression),
-}