thp/src/syntax/mod.rs

26 lines
536 B
Rust
Raw Normal View History

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-23 12:58:53 +00:00
use super::ast_types;
2023-01-05 23:20:58 +00:00
2023-01-23 12:58:53 +00:00
use ast_types::ModuleAST;
2023-01-08 23:09:06 +00:00
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