2022-11-28 23:33:34 +00:00
|
|
|
use super::token::Token;
|
2022-11-21 21:58:51 +00:00
|
|
|
|
2023-01-05 23:20:58 +00:00
|
|
|
mod expression;
|
2023-01-08 23:09:06 +00:00
|
|
|
mod val_binding;
|
2023-01-05 23:20:58 +00:00
|
|
|
mod types;
|
|
|
|
|
2023-01-08 23:09:06 +00:00
|
|
|
use types::ModuleAST;
|
|
|
|
|
2022-11-28 23:33:34 +00:00
|
|
|
/// Constructs the Misti AST from a vector of tokens
|
2023-01-17 13:04:11 +00:00
|
|
|
pub fn construct_ast<'a>(tokens: &'a Vec<Token>) -> Result<ModuleAST<'a>, String> {
|
|
|
|
let maybe_binding = val_binding::try_parse(tokens, 0);
|
|
|
|
|
|
|
|
match maybe_binding {
|
|
|
|
Some(binding) => {
|
|
|
|
Ok(ModuleAST {
|
|
|
|
bindings: vec![binding]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
None => {
|
|
|
|
Err(String::from("Syntax error."))
|
|
|
|
}
|
|
|
|
}
|
2022-11-21 21:58:51 +00:00
|
|
|
}
|
2023-01-05 23:20:58 +00:00
|
|
|
|
|
|
|
|