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

adjust choice of rust nonterminals (and their names) in macro patterns #3379

Closed
jesse99 opened this issue Sep 4, 2012 · 6 comments
Closed
Labels
A-frontend Area: frontend (errors, parsing and HIR) A-grammar Area: The grammar of Rust A-syntaxext Area: Syntax extensions C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@jesse99
Copy link
Contributor

jesse99 commented Sep 4, 2012

Judging from the tutorial it seems that macro fragment matching is done with names coming directly from the grammar. It doesn't seem wise to tie names in user code to the entire grammar that a particular snapshot of a particular rust compiler uses internally. Perhaps it would be better to figure out a subset of non-terminals that are sensible to use in macros and that compilers are free to map however they like internally.

This would also make it easy to provide user-facing names that aren't as aggressively abbreviated as the internal names, e.g. type(?) instead of ty.

@graydon
Copy link
Contributor

graydon commented Sep 5, 2012

No, they're not taken directly from the grammar. It matches a subset of production names, chosen by paul more or less at random based on macros he expects to see people write. This could do with further cleanup but I expect expr and stmt at least are going to be more pleasant, when writing repeatedly, than expression or statement.

@jesse99
Copy link
Contributor Author

jesse99 commented Sep 6, 2012

If it's a fixed subset then they should all be documented in the reference manual (and any, like ty, that aren't obvious need to be explained).

@paulstansifer
Copy link
Contributor

It haven't shown up in the release yet, but the manual now says:

"In the matcher, $ name : designator matches the nonterminal in the
Rust syntax named by designator. Valid designators are item, block,
stmt, pat, expr, ty, ident, path, tt, matchers. The last two
are the right-hand side and the left-hand side respectively of the => in
macro rules."

@graydon
Copy link
Contributor

graydon commented Mar 25, 2013

non-critical for 0.6, de-milestoning

@graydon
Copy link
Contributor

graydon commented Apr 25, 2013

nominating for backwards compatible

(at least deciding this)

@graydon
Copy link
Contributor

graydon commented Apr 25, 2013

Closing as WONTFIX, team thinks this set of names is ok as-is.

@graydon graydon closed this as completed Apr 25, 2013
RalfJung pushed a commit to RalfJung/rust that referenced this issue Mar 15, 2024
explain time-with-isolation test better

Fixes rust-lang/miri#3377

`@saethlin` do you think this is better?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: frontend (errors, parsing and HIR) A-grammar Area: The grammar of Rust A-syntaxext Area: Syntax extensions C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants