implement RFC amendment 1494

This commit is contained in:
Alex Burka 2016-02-08 21:47:57 -05:00
parent 526f2bf5c5
commit 01aebf01bc
3 changed files with 7 additions and 4 deletions

View File

@ -1014,6 +1014,7 @@ fn is_in_follow(_: &ExtCtxt, tok: &Token, frag: &str) -> Result<bool, String> {
match *tok { match *tok {
OpenDelim(token::DelimToken::Brace) | OpenDelim(token::DelimToken::Bracket) | OpenDelim(token::DelimToken::Brace) | OpenDelim(token::DelimToken::Bracket) |
Comma | FatArrow | Colon | Eq | Gt | Semi | BinOp(token::Or) => Ok(true), Comma | FatArrow | Colon | Eq | Gt | Semi | BinOp(token::Or) => Ok(true),
MatchNt(_, ref frag, _, _) if frag.name.as_str() == "block" => Ok(true),
Ident(i, _) if (i.name.as_str() == "as" || Ident(i, _) if (i.name.as_str() == "as" ||
i.name.as_str() == "where") => Ok(true), i.name.as_str() == "where") => Ok(true),
_ => Ok(false) _ => Ok(false)

View File

@ -55,7 +55,7 @@ macro_rules! follow_expr {
($e:expr $m:meta) => {}; //~ERROR `$e:expr` is followed by `$m:meta` ($e:expr $m:meta) => {}; //~ERROR `$e:expr` is followed by `$m:meta`
} }
// FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or, // FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or,
// Ident(as), Ident(where), OpenDelim(Bracket)} // Ident(as), Ident(where), OpenDelim(Bracket), Nonterminal(Block)}
macro_rules! follow_ty { macro_rules! follow_ty {
($t:ty ()) => {}; //~WARN `$t:ty` is followed by `(` ($t:ty ()) => {}; //~WARN `$t:ty` is followed by `(`
($t:ty []) => {}; // ok (RFC 1462) ($t:ty []) => {}; // ok (RFC 1462)
@ -67,7 +67,7 @@ macro_rules! follow_ty {
($t:ty $t:ty) => {}; //~ERROR `$t:ty` is followed by `$t:ty` ($t:ty $t:ty) => {}; //~ERROR `$t:ty` is followed by `$t:ty`
($t:ty $s:stmt) => {}; //~ERROR `$t:ty` is followed by `$s:stmt` ($t:ty $s:stmt) => {}; //~ERROR `$t:ty` is followed by `$s:stmt`
($t:ty $p:path) => {}; //~ERROR `$t:ty` is followed by `$p:path` ($t:ty $p:path) => {}; //~ERROR `$t:ty` is followed by `$p:path`
($t:ty $b:block) => {}; //~ERROR `$t:ty` is followed by `$b:block` ($t:ty $b:block) => {}; // ok (RFC 1494)
($t:ty $i:ident) => {}; //~ERROR `$t:ty` is followed by `$i:ident` ($t:ty $i:ident) => {}; //~ERROR `$t:ty` is followed by `$i:ident`
($t:ty $t:tt) => {}; //~ERROR `$t:ty` is followed by `$t:tt` ($t:ty $t:tt) => {}; //~ERROR `$t:ty` is followed by `$t:tt`
($t:ty $i:item) => {}; //~ERROR `$t:ty` is followed by `$i:item` ($t:ty $i:item) => {}; //~ERROR `$t:ty` is followed by `$i:item`
@ -109,7 +109,7 @@ macro_rules! follow_path {
($p:path $t:ty) => {}; //~ERROR `$p:path` is followed by `$t:ty` ($p:path $t:ty) => {}; //~ERROR `$p:path` is followed by `$t:ty`
($p:path $s:stmt) => {}; //~ERROR `$p:path` is followed by `$s:stmt` ($p:path $s:stmt) => {}; //~ERROR `$p:path` is followed by `$s:stmt`
($p:path $p:path) => {}; //~ERROR `$p:path` is followed by `$p:path` ($p:path $p:path) => {}; //~ERROR `$p:path` is followed by `$p:path`
($p:path $b:block) => {}; //~ERROR `$p:path` is followed by `$b:block` ($p:path $b:block) => {}; // ok (RFC 1494)
($p:path $i:ident) => {}; //~ERROR `$p:path` is followed by `$i:ident` ($p:path $i:ident) => {}; //~ERROR `$p:path` is followed by `$i:ident`
($p:path $t:tt) => {}; //~ERROR `$p:path` is followed by `$t:tt` ($p:path $t:tt) => {}; //~ERROR `$p:path` is followed by `$t:tt`
($p:path $i:item) => {}; //~ERROR `$p:path` is followed by `$i:item` ($p:path $i:item) => {}; //~ERROR `$p:path` is followed by `$i:item`

View File

@ -26,7 +26,7 @@ macro_rules! follow_expr {
($e:expr ;) => {}; ($e:expr ;) => {};
} }
// FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or, // FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or,
// Ident(as), Ident(where), OpenDelim(Bracket)} // Ident(as), Ident(where), OpenDelim(Bracket), Nonterminal(Block)}
macro_rules! follow_ty { macro_rules! follow_ty {
($t:ty {}) => {}; ($t:ty {}) => {};
($t:ty ,) => {}; ($t:ty ,) => {};
@ -39,6 +39,7 @@ macro_rules! follow_ty {
($t:ty as) => {}; ($t:ty as) => {};
($t:ty where) => {}; ($t:ty where) => {};
($t:ty []) => {}; ($t:ty []) => {};
($t:ty $b:block) => {};
} }
// FOLLOW(stmt) = FOLLOW(expr) // FOLLOW(stmt) = FOLLOW(expr)
macro_rules! follow_stmt { macro_rules! follow_stmt {
@ -59,6 +60,7 @@ macro_rules! follow_path {
($p:path as) => {}; ($p:path as) => {};
($p:path where) => {}; ($p:path where) => {};
($p:path []) => {}; ($p:path []) => {};
($p:path $b:block) => {};
} }
// FOLLOW(block) = any token // FOLLOW(block) = any token
macro_rules! follow_block { macro_rules! follow_block {