Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.
Discussion options

You must be logged in to vote

Hey :) So, when trying to do transformations to existing parsers like this, the first thing to consider is: where to .or_not(). Your intuition to use it is correct, though in the parsers current form that won't work. What you need to do is extract the optional part:

let let_ =
    // Let Token (ignored)
    just(Token::Let)
        // list of identifiers
        .ignore_then(
            ident_items
            .clone()
            .map_with(|expr, e| (expr, e.span()))
        )
        // You want from here -- {
        .then_ignore(just(Token::Op("=")))
        // the assigned 
        .then(inline_expr.clone())
        // --  } to here to be optional

        // token semikolon (ignored)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Thewbi
Comment options

Answer selected by Thewbi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants