From 8c88308c68691b795815a776d41b3aa11717c146 Mon Sep 17 00:00:00 2001 From: Kyle Mayes Date: Wed, 11 Nov 2015 15:19:01 -0500 Subject: libsyntax: Add more quasiquoting macros --- src/libsyntax/parse/parser.rs | 18 ++++++++++++++++++ src/libsyntax/parse/token.rs | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fde1058a785..f5e4114464f 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 { + panictry!(self.parse_block()) + } + + pub fn parse_meta_item_panic(&mut self) -> P { + 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 { + 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); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index ba24dc3c0a7..5e4449af604 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -381,12 +381,13 @@ pub enum Nonterminal { NtMeta(P), NtPath(Box), NtTT(P), // needs P'ed to break a circularity - // These is not exposed to macros, but is used by quasiquote. + // These are not exposed to macros, but are used by quasiquote. NtArm(ast::Arm), NtImplItem(P), NtTraitItem(P), NtGenerics(ast::Generics), NtWhereClause(ast::WhereClause), + NtArg(ast::Arg), } impl fmt::Debug for Nonterminal { @@ -407,6 +408,7 @@ impl fmt::Debug for Nonterminal { NtTraitItem(..) => f.pad("NtTraitItem(..)"), NtGenerics(..) => f.pad("NtGenerics(..)"), NtWhereClause(..) => f.pad("NtWhereClause(..)"), + NtArg(..) => f.pad("NtArg(..)"), } } } -- cgit 1.4.1-3-g733a5