include new files

This commit is contained in:
2024-04-09 20:54:55 +02:00
parent 7ecd70561f
commit 186858d668
3 changed files with 41 additions and 0 deletions

12
sample/nothing.pl.xml Normal file
View File

@@ -0,0 +1,12 @@
<program name="nothing">
<main>
<real>
<integer value="5"/>
</real>
<return>
<integer>
<real value="3.0"/>
</integer>
</return>
</main>
</program>

21
src/compiler/context.rs Normal file
View File

@@ -0,0 +1,21 @@
pub struct Context {
variables: Vec<String>,
}
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
})
}
}

View File

@@ -0,0 +1,8 @@
pub enum ValueType {
Integer,
Real,
String,
Array,
Function,
None
}