diff options
| author | bors <bors@rust-lang.org> | 2015-11-12 20:31:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-11-12 20:31:12 +0000 |
| commit | 5a872880bd42f5fc56a3ae35aa05a4e239f5bd35 (patch) | |
| tree | 9ba70793feeae9a817ffdad1b49a1b1ff260e0a5 /src/libsyntax/parse/parser.rs | |
| parent | 15e7824f1ce2f622afc195e72469f3c01f88a1f3 (diff) | |
| parent | 8c88308c68691b795815a776d41b3aa11717c146 (diff) | |
| download | rust-5a872880bd42f5fc56a3ae35aa05a4e239f5bd35.tar.gz rust-5a872880bd42f5fc56a3ae35aa05a4e239f5bd35.zip | |
Auto merge of #29780 - KyleMayes:quote-ext, r=nrc
This is my first code contribution to Rust, so I'm sure there are some issues with the changes I've made. I've added the `quote_arg!`, `quote_block!`, `quote_path!`, and `quote_meta_item!` quasiquoting macros. From my experience trying to build AST in compiler plugins, I would like to be able to build any AST piece with a quasiquoting macro (e.g., `quote_struct_field!` or `quote_variant!`) and then use those AST pieces in other quasiquoting macros, but this pull request just adds some of the low-hanging fruit. I'm not sure if these additions are desirable, and I'm sure these macros can be implemented in an external crate if not.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1e38eebec5d..9219f05d99a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -393,6 +393,22 @@ impl<'a> Parser<'a> { panictry!(self.parse_attribute(permit_inner)) } + pub fn parse_arg_panic(&mut self) -> Arg { + panictry!(self.parse_arg()) + } + + pub fn parse_block_panic(&mut self) -> P<Block> { + panictry!(self.parse_block()) + } + + pub fn parse_meta_item_panic(&mut self) -> P<ast::MetaItem> { + panictry!(self.parse_meta_item()) + } + + pub fn parse_path_panic(&mut self, mode: PathParsingMode) -> ast::Path { + panictry!(self.parse_path(mode)) + } + /// Convert a token to a string using self's reader pub fn token_to_string(token: &token::Token) -> String { pprust::token_to_string(token) @@ -1455,6 +1471,8 @@ impl<'a> Parser<'a> { /// This version of parse arg doesn't necessarily require /// identifier names. pub fn parse_arg_general(&mut self, require_name: bool) -> PResult<Arg> { + maybe_whole!(no_clone self, NtArg); + let pat = if require_name || self.is_named_argument() { debug!("parse_arg_general parse_pat (require_name:{})", require_name); |
