-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Implement ?
macro repetition
#47752
Merged
Merged
Implement ?
macro repetition
#47752
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
760879b
Allow `?` as a KleeneOp in the macro parser
mark-i-m bb8110c
Update the macro parser to allow at most once repetitions for `?` Kleene
mark-i-m c33649c
Run rustfmt on quoted.rs
mark-i-m 711f71c
Add a couple of tests
mark-i-m 5ac48ec
Run rustfmt on macro_parser.rs
mark-i-m f59b821
Attempted fix for `?` kleene op
mark-i-m 51ef739
Fix typo in error message + update tests
mark-i-m 4897a05
Fix a couple of tests
mark-i-m 3c15405
Add feature gate + tests
mark-i-m 5c4b4fe
Corrected ui feature gate test
mark-i-m bd98a93
Fix more tests
mark-i-m 6943430
Add ? to unstable book
mark-i-m 3859eca
Improved tests + typo fixes + assert
mark-i-m 786b2ca
Fix trailing whitespace
mark-i-m 549534e
Update a few comments
mark-i-m 4cf3b65
Use the right tracking issue
mark-i-m 1bd0862
Update feature gate test
mark-i-m b92e542
Fix the test
mark-i-m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# `macro_at_most_once_rep` | ||
|
||
The tracking issue for this feature is: TODO(mark-i-m) | ||
|
||
With this feature gate enabled, one can use `?` as a Kleene operator meaning "0 | ||
or 1 repetitions" in a macro definition. Previously only `+` and `*` were allowed. | ||
|
||
For example: | ||
```rust | ||
macro_rules! foo { | ||
(something $(,)?) // `?` indicates `,` is "optional"... | ||
=> {} | ||
} | ||
``` | ||
|
||
------------------------ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we add
assert_eq!(op, KleeneOp::ZeroOrOne);
here? I find it helps catch mistakes when later somebody messes with the arms accidentally....