plex
plex copied to clipboard
Anyway to have a priority?
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 => ....,
}
}
@goffrie
Requesting the same feature here, as I'm dealing with some issues in my grammar which could be solved with priority.
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.