@@ -83,7 +83,7 @@ use self::TokenTreeOrTokenTreeVec::*;
|
|||||||
use ast;
|
use ast;
|
||||||
use ast::{TokenTree, Ident};
|
use ast::{TokenTree, Ident};
|
||||||
use ast::{TtDelimited, TtSequence, TtToken};
|
use ast::{TtDelimited, TtSequence, TtToken};
|
||||||
use codemap::{BytePos, mk_sp};
|
use codemap::{BytePos, mk_sp, Span};
|
||||||
use codemap;
|
use codemap;
|
||||||
use parse::lexer::*; //resolve bug?
|
use parse::lexer::*; //resolve bug?
|
||||||
use parse::ParseSess;
|
use parse::ParseSess;
|
||||||
@@ -483,11 +483,11 @@ pub fn parse(sess: &ParseSess,
|
|||||||
|
|
||||||
let mut ei = bb_eis.pop().unwrap();
|
let mut ei = bb_eis.pop().unwrap();
|
||||||
match ei.top_elts.get_tt(ei.idx) {
|
match ei.top_elts.get_tt(ei.idx) {
|
||||||
TtToken(_, MatchNt(_, name, _, _)) => {
|
TtToken(span, MatchNt(_, name, _, _)) => {
|
||||||
let name_string = token::get_ident(name);
|
let name_string = token::get_ident(name);
|
||||||
let match_cur = ei.match_cur;
|
let match_cur = ei.match_cur;
|
||||||
(&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal(
|
(&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal(
|
||||||
parse_nt(&mut rust_parser, name_string.get()))));
|
parse_nt(&mut rust_parser, span, name_string.get()))));
|
||||||
ei.idx += 1us;
|
ei.idx += 1us;
|
||||||
ei.match_cur += 1;
|
ei.match_cur += 1;
|
||||||
}
|
}
|
||||||
@@ -505,7 +505,7 @@ pub fn parse(sess: &ParseSess,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal {
|
pub fn parse_nt(p: &mut Parser, sp: Span, name: &str) -> Nonterminal {
|
||||||
match name {
|
match name {
|
||||||
"tt" => {
|
"tt" => {
|
||||||
p.quote_depth += 1us; //but in theory, non-quoted tts might be useful
|
p.quote_depth += 1us; //but in theory, non-quoted tts might be useful
|
||||||
@@ -541,7 +541,11 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal {
|
|||||||
}
|
}
|
||||||
"meta" => token::NtMeta(p.parse_meta_item()),
|
"meta" => token::NtMeta(p.parse_meta_item()),
|
||||||
_ => {
|
_ => {
|
||||||
p.fatal(&format!("unsupported builtin nonterminal parser: {}", name)[])
|
p.span_fatal_help(sp,
|
||||||
|
&format!("invalid fragment specifier `{}`", name)[],
|
||||||
|
"valid fragment specifiers are `ident`, `block`, \
|
||||||
|
`stmt`, `expr`, `pat`, `ty`, `path`, `meta`, `tt` \
|
||||||
|
and `item`")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ fn is_in_follow(_: &ExtCtxt, tok: &Token, frag: &str) -> Result<bool, String> {
|
|||||||
// harmless
|
// harmless
|
||||||
Ok(true)
|
Ok(true)
|
||||||
},
|
},
|
||||||
_ => Err(format!("unrecognized builtin nonterminal `{}`", frag))
|
_ => Err(format!("invalid fragment specifier `{}`", frag))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,6 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
macro_rules! test { ($wrong:t_ty ..) => () }
|
macro_rules! test { ($wrong:t_ty ..) => () }
|
||||||
//~^ ERROR: unrecognized builtin nonterminal `t_ty`
|
//~^ ERROR: invalid fragment specifier `t_ty`
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user