mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
don't leak implementation details
This commit is contained in:
parent
bd61a03ae0
commit
91271d0308
5 changed files with 42 additions and 55 deletions
|
@ -16,11 +16,17 @@ use crate::type_annotation;
|
|||
use bumpalo::collections::Vec;
|
||||
use roc_region::all::Located;
|
||||
|
||||
pub fn header<'a>() -> impl Parser<'a, Module<'a>, SyntaxError<'a>> {
|
||||
specialize(|e, _, _| SyntaxError::Header(e), header_help())
|
||||
pub fn parse_header<'a>(
|
||||
arena: &'a bumpalo::Bump,
|
||||
state: State<'a>,
|
||||
) -> Result<(Module<'a>, State<'a>), EHeader<'a>> {
|
||||
match header().parse(arena, state) {
|
||||
Ok((_, module, state)) => Ok((module, state)),
|
||||
Err((_, fail, _)) => Err(fail),
|
||||
}
|
||||
}
|
||||
|
||||
fn header_help<'a>() -> impl Parser<'a, Module<'a>, EHeader<'a>> {
|
||||
fn header<'a>() -> impl Parser<'a, Module<'a>, EHeader<'a>> {
|
||||
use crate::parser::keyword_e;
|
||||
|
||||
one_of![
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::ast;
|
||||
use crate::blankspace::space0_before;
|
||||
use crate::expr::expr;
|
||||
use crate::module::{header, module_defs};
|
||||
use crate::module::module_defs;
|
||||
use crate::parser::{loc, Parser, State, SyntaxError};
|
||||
use bumpalo::collections::Vec;
|
||||
use bumpalo::Bump;
|
||||
|
@ -14,18 +14,6 @@ pub fn parse_expr_with<'a>(
|
|||
parse_loc_with(arena, input).map(|loc_expr| loc_expr.value)
|
||||
}
|
||||
|
||||
pub fn parse_header_with<'a>(
|
||||
arena: &'a Bump,
|
||||
input: &'a str,
|
||||
) -> Result<ast::Module<'a>, SyntaxError<'a>> {
|
||||
let state = State::new_in(arena, input.trim().as_bytes());
|
||||
let answer = header().parse(arena, state);
|
||||
|
||||
answer
|
||||
.map(|(_, loc_expr, _)| loc_expr)
|
||||
.map_err(|(_, fail, _)| fail)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn parse_defs_with<'a>(
|
||||
arena: &'a Bump,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue