Implement block / indent based parsing

... and enforce that defs can only occur in blocks (or, inside parenthesized expressions)
This commit is contained in:
Joshua Warner 2024-07-08 21:14:51 -07:00
parent d5db3137a3
commit 4f32f43048
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
304 changed files with 12050 additions and 8876 deletions

View file

@ -22,7 +22,7 @@ pub fn parse_loc_with<'a>(
arena: &'a Bump,
input: &'a str,
) -> Result<Loc<ast::Expr<'a>>, SourceError<'a, SyntaxError<'a>>> {
let state = State::new(input.trim().as_bytes());
let state = State::new(input.as_bytes());
match crate::expr::test_parse_expr(0, arena, state.clone()) {
Ok(loc_expr) => Ok(loc_expr),
@ -31,7 +31,7 @@ pub fn parse_loc_with<'a>(
}
pub fn parse_defs_with<'a>(arena: &'a Bump, input: &'a str) -> Result<Defs<'a>, SyntaxError<'a>> {
let state = State::new(input.trim().as_bytes());
let state = State::new(input.as_bytes());
parse_module_defs(arena, state, Defs::default())
}
@ -40,7 +40,7 @@ pub fn parse_header_with<'a>(
arena: &'a Bump,
input: &'a str,
) -> Result<ast::Module<'a>, SyntaxError<'a>> {
let state = State::new(input.trim().as_bytes());
let state = State::new(input.as_bytes());
match crate::module::parse_header(arena, state.clone()) {
Ok((header, _)) => Ok(header),