break out the parser and compiler into their own libraries

This commit is contained in:
2025-06-15 22:24:30 -07:00
parent 8280d45366
commit e32e941e14
9 changed files with 60 additions and 21 deletions

View File

@@ -1,9 +1,6 @@
#[macro_use]
extern crate quick_error;
mod compiler;
mod parser;
use clap::Parser;
use compiler::Compiler;
use parser::Parser as ASTParser;
@@ -14,14 +11,6 @@ use std::{
};
use tokenizer::{Tokenizer, TokenizerError};
#[macro_export]
/// A macro to create a boxed value.
macro_rules! boxed {
($e:expr) => {
Box::new($e)
};
}
quick_error! {
#[derive(Debug)]
enum StationlangError {
@@ -78,8 +67,8 @@ fn run_logic() -> Result<(), StationlangError> {
let parser = ASTParser::new(tokenizer);
let mut writer: BufWriter<Box<dyn Write>> = match args.output_file {
Some(output_file) => BufWriter::new(boxed!(File::create(output_file)?)),
None => BufWriter::new(boxed!(std::io::stdout())),
Some(output_file) => BufWriter::new(Box::new(File::create(output_file)?)),
None => BufWriter::new(Box::new(std::io::stdout())),
};
let compiler = Compiler::new(parser, &mut writer);