From 186858d668ba777e90485a05e97097d1a05897f7 Mon Sep 17 00:00:00 2001 From: Altareos Date: Tue, 9 Apr 2024 20:54:55 +0200 Subject: [PATCH] include new files --- sample/nothing.pl.xml | 12 ++++++++++++ src/compiler/context.rs | 21 +++++++++++++++++++++ src/compiler/value_type.rs | 8 ++++++++ 3 files changed, 41 insertions(+) create mode 100644 sample/nothing.pl.xml create mode 100644 src/compiler/context.rs create mode 100644 src/compiler/value_type.rs diff --git a/sample/nothing.pl.xml b/sample/nothing.pl.xml new file mode 100644 index 0000000..efe7535 --- /dev/null +++ b/sample/nothing.pl.xml @@ -0,0 +1,12 @@ + +
+ + + + + + + + +
+
\ No newline at end of file diff --git a/src/compiler/context.rs b/src/compiler/context.rs new file mode 100644 index 0000000..6b6acbe --- /dev/null +++ b/src/compiler/context.rs @@ -0,0 +1,21 @@ +pub struct Context { + variables: Vec, +} + +impl Context { + pub fn new() -> Self { + Context { + variables: Vec::new(), + } + } + + pub fn variable_offset(&mut self, var: &String) -> usize { + self.variables + .iter() + .position(|p| p == var) + .unwrap_or_else(|| { + self.variables.push(var.clone()); + self.variables.len() - 1 + }) + } +} diff --git a/src/compiler/value_type.rs b/src/compiler/value_type.rs new file mode 100644 index 0000000..e6e4717 --- /dev/null +++ b/src/compiler/value_type.rs @@ -0,0 +1,8 @@ +pub enum ValueType { + Integer, + Real, + String, + Array, + Function, + None +} \ No newline at end of file