use lalrpop_util::lalrpop_mod;
use aleph_syntax_tree::syntax::AlephTree as at;
lalrpop_mod!(pub grammar);
pub fn parse(source: String) -> at {
let ast = grammar::ProgramParser::new().parse(&source);
match ast {
Ok(res) => res,
Err(e) => {
eprintln!("Parse error: {:?}", e);
at::Unit
}
}
}
pub fn parse_ada_declarations(source: String) -> Vec<Box<at>> {
let ast = grammar::DeclarationListParser::new().parse(&source);
match ast {
Ok(res) => res,
Err(e) => {
eprintln!("Parse error: {:?}", e);
Vec::new()
}
}
}
pub fn parse_ada_statements(source: String) -> Vec<Box<at>> {
let ast = grammar::StatementListParser::new().parse(&source);
match ast {
Ok(res) => res,
Err(e) => {
eprintln!("Parse error: {:?}", e);
Vec::new()
}
}
}