Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyway to have a priority? #49

Closed
lemonlambda opened this issue Aug 28, 2022 · 3 comments
Closed

Anyway to have a priority? #49

lemonlambda opened this issue Aug 28, 2022 · 3 comments

Comments

@lemonlambda
Copy link

lemonlambda commented Aug 28, 2022

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
Copy link
Author

@goffrie

@maxrdz
Copy link

maxrdz commented Sep 27, 2023

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

@goffrie
Copy link
Owner

goffrie commented Sep 27, 2023

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.

Repository owner locked and limited conversation to collaborators Sep 27, 2023
@goffrie goffrie converted this issue into discussion #51 Sep 27, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants