mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Extract parse_expr_body_without_operators
This commit is contained in:
parent
4ac9a51e1e
commit
1054c3318b
1 changed files with 17 additions and 8 deletions
|
@ -30,14 +30,7 @@ pub fn expr<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>> {
|
||||||
fn parse_expr<'a>(min_indent: u16, arena: &'a Bump, state: State<'a>) -> ParseResult<'a, Expr<'a>> {
|
fn parse_expr<'a>(min_indent: u16, arena: &'a Bump, state: State<'a>) -> ParseResult<'a, Expr<'a>> {
|
||||||
let expr_parser = map_with_arena(
|
let expr_parser = map_with_arena(
|
||||||
and(
|
and(
|
||||||
loc(one_of6(
|
loc(move |arena, state| parse_expr_body_without_operators(min_indent, arena, state)),
|
||||||
string_literal(),
|
|
||||||
record_literal(),
|
|
||||||
number_literal(),
|
|
||||||
when(min_indent),
|
|
||||||
conditional(min_indent),
|
|
||||||
ident_etc(min_indent),
|
|
||||||
)),
|
|
||||||
optional(and(
|
optional(and(
|
||||||
and(space0(min_indent), and(loc(operator()), space0(min_indent))),
|
and(space0(min_indent), and(loc(operator()), space0(min_indent))),
|
||||||
loc(move |arena, state| parse_expr(min_indent, arena, state)),
|
loc(move |arena, state| parse_expr(min_indent, arena, state)),
|
||||||
|
@ -68,6 +61,22 @@ fn parse_expr<'a>(min_indent: u16, arena: &'a Bump, state: State<'a>) -> ParseRe
|
||||||
attempt(Attempting::Expression, expr_parser).parse(arena, state)
|
attempt(Attempting::Expression, expr_parser).parse(arena, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_expr_body_without_operators<'a>(
|
||||||
|
min_indent: u16,
|
||||||
|
arena: &'a Bump,
|
||||||
|
state: State<'a>,
|
||||||
|
) -> ParseResult<'a, Expr<'a>> {
|
||||||
|
one_of6(
|
||||||
|
string_literal(),
|
||||||
|
record_literal(),
|
||||||
|
number_literal(),
|
||||||
|
when(min_indent),
|
||||||
|
conditional(min_indent),
|
||||||
|
ident_etc(min_indent),
|
||||||
|
)
|
||||||
|
.parse(arena, state)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn loc_function_args<'a>(_min_indent: u16) -> impl Parser<'a, &'a [Located<Expr<'a>>]> {
|
pub fn loc_function_args<'a>(_min_indent: u16) -> impl Parser<'a, &'a [Located<Expr<'a>>]> {
|
||||||
move |_arena, _state| {
|
move |_arena, _state| {
|
||||||
panic!("TODO stop early if we see an operator after the whitespace - precedence!");
|
panic!("TODO stop early if we see an operator after the whitespace - precedence!");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue