mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
progress on setting up def parser for top level defs
This commit is contained in:
parent
435789b807
commit
5023fa3e75
8 changed files with 107 additions and 21 deletions
|
@ -1,8 +1,11 @@
|
|||
use crate::ast;
|
||||
use crate::module::module_defs;
|
||||
// use crate::module::module_defs;
|
||||
use crate::parser::{State, SyntaxError};
|
||||
use bumpalo::Bump;
|
||||
use bumpalo::collections::Vec as BumpVec;
|
||||
use roc_region::all::Located;
|
||||
use crate::parser::Parser;
|
||||
|
||||
pub fn parse_expr_with<'a>(
|
||||
arena: &'a Bump,
|
||||
|
@ -23,3 +26,15 @@ pub fn parse_loc_with<'a>(
|
|||
Err(fail) => Err(SyntaxError::Expr(fail)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_defs_with<'a>(
|
||||
arena: &'a Bump,
|
||||
input: &'a str,
|
||||
) -> Result<BumpVec<'a, Located<ast::Def<'a>>>, SyntaxError<'a>> {
|
||||
let state = State::new(input.trim().as_bytes());
|
||||
|
||||
match module_defs().parse(arena, state) {
|
||||
Ok(tuple) => Ok(tuple.1),
|
||||
Err(tuple) => Err(tuple.1),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue