mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-29 01:13:47 +00:00
print all the relevant info
This commit is contained in:
parent
e7f3c6f281
commit
e44a8a9eed
17 changed files with 308 additions and 12 deletions
|
@ -208,6 +208,7 @@ pub enum Expr<'a> {
|
|||
Defs(&'a Defs<'a>, &'a Loc<Expr<'a>>),
|
||||
Backpassing(&'a [Loc<Pattern<'a>>], &'a Loc<Expr<'a>>, &'a Loc<Expr<'a>>),
|
||||
Expect(&'a Loc<Expr<'a>>, &'a Loc<Expr<'a>>),
|
||||
Dbg(&'a Loc<Expr<'a>>, &'a Loc<Expr<'a>>),
|
||||
|
||||
// Application
|
||||
/// To apply by name, do Apply(Var(...), ...)
|
||||
|
|
|
@ -327,6 +327,7 @@ fn expr_start<'a>(options: ExprParseOptions) -> impl Parser<'a, Loc<Expr<'a>>, E
|
|||
loc!(specialize(EExpr::If, if_expr_help(options))),
|
||||
loc!(specialize(EExpr::When, when::expr_help(options))),
|
||||
loc!(specialize(EExpr::Expect, expect_help(options))),
|
||||
loc!(specialize(EExpr::Dbg, dbg_help(options))),
|
||||
loc!(specialize(EExpr::Closure, closure_help(options))),
|
||||
loc!(expr_operator_chain(options)),
|
||||
fail_expr_start_e()
|
||||
|
@ -1912,6 +1913,7 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result<Pattern<
|
|||
| Expr::If(_, _)
|
||||
| Expr::When(_, _)
|
||||
| Expr::Expect(_, _)
|
||||
| Expr::Dbg(_, _)
|
||||
| Expr::MalformedClosure
|
||||
| Expr::PrecedenceConflict { .. }
|
||||
| Expr::RecordUpdate { .. }
|
||||
|
@ -2330,6 +2332,36 @@ fn expect_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EExpe
|
|||
}
|
||||
}
|
||||
|
||||
fn dbg_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EExpect<'a>> {
|
||||
move |arena: &'a Bump, state: State<'a>, min_indent| {
|
||||
let start_column = state.column();
|
||||
|
||||
let (_, _, state) =
|
||||
parser::keyword_e(keyword::DBG, EExpect::Dbg).parse(arena, state, min_indent)?;
|
||||
|
||||
let (_, condition, state) = space0_before_e(
|
||||
specialize_ref(
|
||||
EExpect::Condition,
|
||||
set_min_indent(start_column + 1, expr_start(options)),
|
||||
),
|
||||
EExpect::IndentCondition,
|
||||
)
|
||||
.parse(arena, state, start_column + 1)
|
||||
.map_err(|(_, f)| (MadeProgress, f))?;
|
||||
|
||||
let parse_cont = specialize_ref(
|
||||
EExpect::Continuation,
|
||||
space0_before_e(loc_expr(), EExpr::IndentEnd),
|
||||
);
|
||||
|
||||
let (_, loc_cont, state) = parse_cont.parse(arena, state, min_indent)?;
|
||||
|
||||
let expr = Expr::Dbg(arena.alloc(condition), arena.alloc(loc_cont));
|
||||
|
||||
Ok((MadeProgress, expr, state))
|
||||
}
|
||||
}
|
||||
|
||||
fn if_expr_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EIf<'a>> {
|
||||
move |arena: &'a Bump, state, min_indent| {
|
||||
let (_, _, state) =
|
||||
|
|
|
@ -354,6 +354,7 @@ pub enum EExpr<'a> {
|
|||
If(EIf<'a>, Position),
|
||||
|
||||
Expect(EExpect<'a>, Position),
|
||||
Dbg(EExpect<'a>, Position),
|
||||
|
||||
Closure(EClosure<'a>, Position),
|
||||
Underscore(Position),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue