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

Macro future proofing #550

Merged
merged 13 commits into from
Jan 19, 2015
Merged

Macro future proofing #550

merged 13 commits into from
Jan 19, 2015

Conversation

emberian
Copy link
Member

@emberian emberian commented Jan 3, 2015

@emberian
Copy link
Member Author

emberian commented Jan 3, 2015

# Unresolved questions

1. What should the FOLLOW sets for `item`, `path`, and `meta` be?
2. Should the `FOLLOW` set for `ty` be extended? In practice, `RArrow`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot one, of course: =

@nrc
Copy link
Member

nrc commented Jan 4, 2015

Oh, and a massive +1 to the overall idea here.

@pczarn
Copy link

pczarn commented Jan 4, 2015

+1, I'm convinced this is necessary. Detailed futures of some NTs are a bit unclear, though.

@emberian
Copy link
Member Author

emberian commented Jan 5, 2015

rust-lang/rust#20563

@nrc
Copy link
Member

nrc commented Jan 15, 2015

@cmr are there any changes you'd like to make to this RFC before we merge it?

@emberian
Copy link
Member Author

@nick29581 maybe. The algorithm here no longer reflects the implementation, and the follow sets are subtly incorrect.

@nrc
Copy link
Member

nrc commented Jan 15, 2015

@cmr Ok, ping me when you are happy and I'll merge it

@emberian
Copy link
Member Author

@nick29581 this is ready.

@nrc nrc merged commit b61c42a into rust-lang:master Jan 19, 2015

- `FOLLOW(pat)` = `{FatArrow, Comma, Eq}`
- `FOLLOW(expr)` = `{FatArrow, Comma, Semicolon}`
- `FOLLOW(ty)` = `{Comma, FatArrow, Colon, Eq, Gt, Ident(as)}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmr, was there a reason for not including Semicolon on this list as well?
It's handy when defining matchers like $( fn $n:ident( $(p:ident : $t:ty),* ) -> $r:ty ; )* (note the trailing 'ty')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that was indeed an oversight

sent from my phone
On Jan 23, 2015 12:24 AM, "Vadim Chugunov" [email protected] wrote:

In text/0000-macro-future-proofing.md
#550 (comment):

  •   continue, else, reject.
    
    1. If T has the form $(...)U+ or $(...)U* for some token U, run
  •   the algorithm on the contents with `F` set to `U`. If it accepts,
    
  •   check that the last token in the sequence can be followed by `F`. If
    
  •   so, accept. Otherwise, reject.
    
    +This algorithm should be run on every matcher in every macro_rules
    +invocation, with F as EOF. If it rejects a matcher, an error should be
    +emitted and compilation should not complete.
    +
    +The current legal fragment specifiers are: item, block, stmt, pat,
    +expr, ty, ident, path, meta, and tt.
    +
    +- FOLLOW(pat) = {FatArrow, Comma, Eq}
    +- FOLLOW(expr) = {FatArrow, Comma, Semicolon}
    +- FOLLOW(ty) = {Comma, FatArrow, Colon, Eq, Gt, Ident(as)}

@cmr https://github.com/cmr, was there a reason for not including
Semicolon on this list as well?
It's handy when defining matchers like $( fn $n:ident( $(p:ident :
$t:ty),* ) -> $r:ty ; )* (note the trailing 'ty')


Reply to this email directly or view it on GitHub
https://github.com/rust-lang/rfcs/pull/550/files#r23432570.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Macro related proposals and issues A-syntax Syntax related proposals & ideas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants