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