diff options
| author | Piotr Czarnecki <pioczarn@gmail.com> | 2014-10-07 00:18:24 +0100 |
|---|---|---|
| committer | Piotr Czarnecki <pioczarn@gmail.com> | 2014-11-05 23:06:01 +0100 |
| commit | 6f30a4ee6c35342cc2775d77882ad26fc31ba61e (patch) | |
| tree | 91b1dd2f9aa3ecc25cbe88193b2db99adb524d02 /src/libsyntax/ext | |
| parent | 38ce6d9eac5d0bcfa0c102bc64393a987b4a43e3 (diff) | |
| download | rust-6f30a4ee6c35342cc2775d77882ad26fc31ba61e.tar.gz rust-6f30a4ee6c35342cc2775d77882ad26fc31ba61e.zip | |
Remove `Matcher`s
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 26 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 10 |
2 files changed, 19 insertions, 17 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 022e3a56677..833211f53e7 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -78,7 +78,7 @@ use ast; -use ast::{Matcher, TokenTree, Ident}; +use ast::{TokenTree, Ident}; use ast::{TtDelimited, TtSequence, TtToken}; use codemap::{BytePos, mk_sp}; use codemap; @@ -97,9 +97,8 @@ use std::rc::Rc; use std::collections::HashMap; use std::collections::hash_map::{Vacant, Occupied}; -/* to avoid costly uniqueness checks, we require that `MatchSeq` always has a -nonempty body. */ - +// To avoid costly uniqueness checks, we require that `MatchSeq` always has +// a nonempty body. /// an unzipping of `TokenTree`s #[deriving(Clone)] @@ -157,22 +156,22 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: ByteP } } -/// NamedMatch is a pattern-match result for a single ast::MatchNonterminal: +/// NamedMatch is a pattern-match result for a single token::MATCH_NONTERMINAL: /// so it is associated with a single ident in a parse, and all -/// MatchedNonterminal's in the NamedMatch have the same nonterminal type -/// (expr, item, etc). All the leaves in a single NamedMatch correspond to a -/// single matcher_nonterminal in the ast::Matcher that produced it. +/// `MatchedNonterminal`s in the NamedMatch have the same nonterminal type +/// (expr, item, etc). Each leaf in a single NamedMatch corresponds to a +/// single token::MATCH_NONTERMINAL in the TokenTree that produced it. /// /// The in-memory structure of a particular NamedMatch represents the match /// that occurred when a particular subset of a matcher was applied to a /// particular token tree. /// /// The width of each MatchedSeq in the NamedMatch, and the identity of the -/// MatchedNonterminal's, will depend on the token tree it was applied to: each -/// MatchedSeq corresponds to a single MatchSeq in the originating -/// ast::Matcher. The depth of the NamedMatch structure will therefore depend -/// only on the nesting depth of ast::MatchSeq's in the originating -/// ast::Matcher it was derived from. +/// `MatchedNonterminal`s, will depend on the token tree it was applied to: +/// each MatchedSeq corresponds to a single TTSeq in the originating +/// token tree. The depth of the NamedMatch structure will therefore depend +/// only on the nesting depth of `ast::TTSeq`s in the originating +/// token tree it was derived from. pub enum NamedMatch { MatchedSeq(Vec<Rc<NamedMatch>>, codemap::Span), @@ -512,7 +511,6 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal { p.quote_depth -= 1u; res } - "matchers" => token::NtMatchers(p.parse_matchers()), _ => { p.fatal(format!("unsupported builtin nonterminal parser: {}", name).as_slice()) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index cbf34ba5eb3..381e4310d89 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{Ident, Matcher_, Matcher, MatchTok, MatchNonterminal, MatchSeq, TtDelimited}; -use ast::{TtSequence, TtToken}; +use ast::{Ident, TtDelimited, TtSequence, TtToken}; use ast; use codemap::{Span, DUMMY_SP}; use ext::base::{ExtCtxt, MacResult, MacroDef}; @@ -21,7 +20,7 @@ use parse::lexer::new_tt_reader; use parse::parser::Parser; use parse::attr::ParserAttr; use parse::token::{special_idents, gensym_ident}; -use parse::token::{MatchNt, NtMatchers, NtTT}; +use parse::token::{MatchNt, NtTT}; use parse::token; use print; use ptr::P; @@ -207,6 +206,11 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, cx.span_fatal(best_fail_spot, best_fail_msg.as_slice()); } +// Note that macro-by-example's input is also matched against a token tree: +// $( $lhs:tt => $rhs:tt );+ +// +// Holy self-referential! + /// This procedure performs the expansion of the /// macro_rules! macro. It parses the RHS and adds /// an extension to the current context. |
