This commit is contained in:
Folkert 2021-02-03 22:42:22 +01:00
parent feb77b5bcc
commit db7e604643
6 changed files with 19 additions and 26 deletions

View file

@ -580,7 +580,7 @@ type Body<'a> = (Located<Pattern<'a>>, Located<Expr<'a>>);
fn body<'a>(min_indent: u16) -> impl Parser<'a, Body<'a>> {
let indented_more = min_indent + 1;
let result = and!(
and!(
// this backtrackable is required for the case
//
// i = 64
@ -601,8 +601,7 @@ fn body<'a>(min_indent: u16) -> impl Parser<'a, Body<'a>> {
.parse(a, s)
}
)
);
result
)
}
fn body_at_indent<'a>(indent_level: u16) -> impl Parser<'a, Body<'a>> {

View file

@ -297,14 +297,8 @@ pub fn platform_header<'a>() -> impl Parser<'a, PlatformHeader<'a>> {
#[inline(always)]
pub fn module_defs<'a>() -> impl Parser<'a, Vec<'a, Located<Def<'a>>>> {
move |a: &'a Bump, s: State<'a>| {
// this parses just the defs
let defs = zero_or_more!(space0_around(loc(def(0)), 0));
let result = skip_second!(defs, end_of_file()).parse(a, s);
result
}
// force that we pare until the end of the input
skip_second!(zero_or_more!(space0_around(loc(def(0)), 0)), end_of_file())
}
struct ProvidesTo<'a> {

View file

@ -75,7 +75,7 @@ impl<'a> State<'a> {
/// Returns whether the parser has reached the end of the input
pub fn has_reached_end(&self) -> bool {
self.bytes.len() == 0
self.bytes.is_empty()
}
/// Increments the line, then resets column, indent_col, and is_indenting.
@ -274,7 +274,7 @@ pub enum ContextStack<'a> {
}
impl<'a> ContextStack<'a> {
fn to_vec(self) -> std::vec::Vec<ContextItem> {
fn into_vec(self) -> std::vec::Vec<ContextItem> {
let mut result = std::vec::Vec::new();
let mut next = &self;
@ -338,15 +338,15 @@ impl<'a> Bag<'a> {
self.0.pop()
}
pub fn to_parse_problem<'b>(
pub fn into_parse_problem(
mut self,
filename: std::path::PathBuf,
bytes: &'b [u8],
) -> ParseProblem<'b> {
bytes: &[u8],
) -> ParseProblem<'_> {
match self.pop() {
None => unreachable!("there is a parse error, but no problem"),
Some(dead_end) => {
let context_stack = dead_end.context_stack.to_vec();
let context_stack = dead_end.context_stack.into_vec();
ParseProblem {
line: dead_end.line,
@ -792,8 +792,8 @@ where
}
}
Err((element_progress, fail, new_state)) => match element_progress {
MadeProgress => return Err((MadeProgress, fail, new_state)),
NoProgress => return Ok((NoProgress, Vec::new_in(arena), new_state)),
MadeProgress => Err((MadeProgress, fail, new_state)),
NoProgress => Ok((NoProgress, Vec::new_in(arena), new_state)),
},
}
}
@ -849,8 +849,8 @@ where
}
}
Err((element_progress, fail, new_state)) => match element_progress {
MadeProgress => return Err((MadeProgress, fail, new_state)),
NoProgress => return Ok((NoProgress, Vec::new_in(arena), new_state)),
MadeProgress => Err((MadeProgress, fail, new_state)),
NoProgress => Ok((NoProgress, Vec::new_in(arena), new_state)),
},
}
}