checkpoint; builds again

This commit is contained in:
2023-12-02 22:38:44 -08:00
parent 71228b9e09
commit 93cac44a99
16 changed files with 1200 additions and 1194 deletions

View File

@@ -1,8 +1,8 @@
use super::ast::{Expression, Program, Statement, TopLevel};
use super::ast::{Expression, Program, TopLevel};
use internment::ArcIntern;
use std::collections::HashSet;
impl Program {
impl<T> Program<T> {
/// Get the complete list of strings used within the program.
///
/// For the purposes of this function, strings are the variables used in
@@ -18,37 +18,18 @@ impl Program {
}
}
impl TopLevel {
impl<T> TopLevel<T> {
fn register_strings(&self, string_set: &mut HashSet<ArcIntern<String>>) {
match self {
TopLevel::Function(_, _, stmts, body) => {
for stmt in stmts.iter() {
stmt.register_strings(string_set);
}
body.register_strings(string_set);
}
TopLevel::Function(_, _, _, body) => body.register_strings(string_set),
TopLevel::Statement(stmt) => stmt.register_strings(string_set),
}
}
}
impl Statement {
fn register_strings(&self, string_set: &mut HashSet<ArcIntern<String>>) {
match self {
Statement::Binding(_, name, _, expr) => {
string_set.insert(name.clone());
expr.register_strings(string_set);
}
Statement::Print(_, _, name) => {
string_set.insert(name.clone());
}
}
}
}
impl Expression {
impl<T> Expression<T> {
fn register_strings(&self, _string_set: &mut HashSet<ArcIntern<String>>) {
// nothing has a string in here, at the moment
unimplemented!()
}
}