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

Better integration between MBE and procedural macros #17396

Closed
kmcallister opened this issue Sep 19, 2014 · 2 comments · Fixed by #22061
Closed

Better integration between MBE and procedural macros #17396

kmcallister opened this issue Sep 19, 2014 · 2 comments · Fixed by #22061
Labels
A-syntaxext Area: Syntax extensions C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@kmcallister
Copy link
Contributor

For example, it should be easy to procedurally invoke the MBE engine's LHS matcher on an arbitrary token tree. This could take a lot of the tedium out of argument parsing in procedural macros.

@pczarn
Copy link
Contributor

pczarn commented Sep 23, 2014

Even the comments in libsyntax ask for a solution:

/// This procedure performs the expansion of the
/// macro_rules! macro. It parses the RHS and adds
/// an extension to the current context.
pub fn add_new_extension<'cx>(
    // ...

    // The pattern that macro_rules matches.
    // The grammar for macro_rules! is:
    // $( $lhs:mtcs => $rhs:tt );+
    // ...quasiquoting this would be nice.
    let argument_gram = vec!(
        ms(MatchSeq(vec!(
            ms(MatchNonterminal(lhs_nm, special_idents::matchers, 0u)),
            ms(MatchTok(FAT_ARROW)),
            ms(MatchNonterminal(rhs_nm, special_idents::tt, 1u))), Some(SEMI), false, 0u, 2u)),
        //to phase into semicolon-termination instead of
        //semicolon-separation
        ms(MatchSeq(vec!(ms(MatchTok(SEMI))), None, true, 2u, 2u)));
    // ...

I'll investigate this.

Edit: this requires some kind of a matcher!() macro -- any ideas?

@kmcallister kmcallister added A-syntaxext Area: Syntax extensions C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Sep 27, 2014
@steveklabnik
Copy link
Member

#17830 was merged, so i'm giving this a close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants