<commit_before>use analysis::table::Table;
use ast::Expression;
use error::ErrorStack;
use to_javascript::ToJavaScript;

#[derive(Debug)]
struct Compiler {
    global: Table<Expression>,
    errors: ErrorStack,
}

impl Compiler {
    fn new() -> Compiler {
        Compiler {
            global: Table::new(None),
            errors: ErrorStack(vec![]),
        }
    }

    fn compile(tree: &[Expression]) -> String {
        tree
            .iter()
            // TODO: Remove unwrap
            .map(|expr| expr.eval().unwrap())
            .collect::<Vec<String>>()
            .join(";")
    }
}
<commit_msg>Make compiler struct and functions public, handle errors<commit_after>use analysis::table::Table;
use ast::Expression;
use error::ErrorStack;
use to_javascript::ToJavaScript;

#[derive(Debug)]
pub struct Compiler {
    global: Table<Expression>,
    errors: ErrorStack,
}

impl Compiler {
    pub fn new() -> Compiler {
        Compiler {
            global: Table::new(None),
            errors: ErrorStack(vec![]),
        }
    }

    pub fn compile(&mut self, tree: &[Expression]) -> String {
        tree
            .iter()
            // TODO: Remove unwrap
            .map(|expr| expr.eval())
            .filter_map(move |expr| {
                if expr.is_err() {
                    self.errors.0.push(expr.clone().unwrap_err());
                }

                expr.ok()
            })
            .collect::<Vec<String>>()
            .join(";")
    }
}

{'fraction_non_alphanumeric': 0.14612794612794613, 'fraction_numerical': 0.0006734006734006734, 'mean_word_length': 1.8854368932038834, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2590116', 'n_tokens_mistral': 432, 'n_tokens_neox': 426, 'n_words': 94}