PNC for Patterns, stabilize formatting

This commit is contained in:
Anthony Bullard 2024-12-31 08:25:11 -06:00
parent bac165fd99
commit 3b0db07fa1
No known key found for this signature in database
78 changed files with 789 additions and 332 deletions

View file

@ -1,6 +1,7 @@
use crate::ast;
use crate::ast::Defs;
use crate::ast::Header;
use crate::ast::Pattern;
use crate::ast::SpacesBefore;
use crate::header::parse_module_defs;
use crate::parser::SourceError;
@ -32,6 +33,18 @@ pub fn parse_loc_with<'a>(
}
}
pub fn parse_pattern_with<'a>(
arena: &'a Bump,
input: &'a str,
) -> Result<Loc<Pattern<'a>>, SourceError<'a, SyntaxError<'a>>> {
let state = State::new(input.as_bytes());
match crate::pattern::test_parse_pattern(0, arena, state.clone()) {
Ok(loc_patt) => Ok(loc_patt),
Err(fail) => Err(SyntaxError::Pattern(fail).into_source_error(&state)),
}
}
pub fn parse_defs_with<'a>(arena: &'a Bump, input: &'a str) -> Result<Defs<'a>, SyntaxError<'a>> {
let state = State::new(input.as_bytes());