plex icon indicating copy to clipboard operation
plex copied to clipboard

Anyway to have a priority?

Open lemonlambda opened this issue 2 years ago • 1 comments

Like this for example

plex::parser! {
    fn parse_(Token, Span);

    // combine two spans
    (a, b) {
        Span {
            lo: a.lo,
            hi: b.hi,
        }
    }

    program: Program {
        statements[s] => Program { stmts: s }
    }

    statements: Vec<Expr> {
        => vec![],
        statements[mut st] outer[e] SemiColon => {
            st.push(e);
            st
        }
    }

    outer: Expr {
        #[priority]
        Token SemiColon => ...,
        inner[a] => a,
    }
    
    inner: Expr {
        Token => ....,
    }
}

lemonlambda avatar Aug 28 '22 06:08 lemonlambda

@goffrie

lemonlambda avatar Aug 28 '22 20:08 lemonlambda

Requesting the same feature here, as I'm dealing with some issues in my grammar which could be solved with priority.

maxrdz avatar Sep 27 '23 05:09 maxrdz

Yes, there's the #[overriding] attribute that gives a rule precedence over other rules. There isn't any syntax for multiple priority levels but it is supported in the underlying LALR(1) library so it should be simple enough to add.

goffrie avatar Sep 27 '23 06:09 goffrie