Skip to content
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

Accept type parameters on grammar (e.g. lifetimes) (Fixes #220) #254

Merged
merged 1 commit into from
Mar 14, 2021

Commits on Mar 13, 2021

  1. Accept type parameters on grammar (e.g. lifetimes)

    This allows the parser to operate over types like `Token<'code>` by
    supplying the lifetime as a type parameter on the grammar:
    
    ```
    peg::parser! {
        grammar feeny<'a>() for Tokens<'a> {
            // snip
        }
    }
    ```
    
    This should work with all type parameters, not just lifetimes, but
    lifetimes are the motivating example here.
    
    Like @kevinmehall's comment on kevinmehall#220 suggests, this simply adds
    `rust_ty_params()` to `peg_grammar` in the meta-grammar, and then
    threads that through.
    
    If a rule defines it's own type parameters, those come after the
    grammar's type parameters on the parser's exported
    functions/entrypoints.
    
    Fixes kevinmehall#220
    bgw committed Mar 13, 2021
    Configuration menu
    Copy the full SHA
    6b19369 View commit details
    Browse the repository at this point in the history