24 lines
705 B
Rust
24 lines
705 B
Rust
pub mod errors;
|
|
|
|
use errors::{Result, ExecutionError};
|
|
|
|
use albireo::{Expression, Type, Identifier, Module, Declaration};
|
|
|
|
// TODO: accepting a module map not a module
|
|
pub fn run_program(module: Module) -> Result<()> {
|
|
let main = module.declaration.get(&Identifier { name: "main".into() })
|
|
.ok_or(ExecutionError::MainNotFound)?;
|
|
|
|
// expecting main to be function receiving no parameter
|
|
if let Declaration::Variable(_, Type::Function(input, _), _) = main {
|
|
if input.len() != 0 {
|
|
return Err(ExecutionError::MainSignatureIncorrect)
|
|
}
|
|
} else {
|
|
return Err(ExecutionError::MainSignatureIncorrect)
|
|
};
|
|
|
|
println!("main {:?}", main);
|
|
Ok(())
|
|
}
|