syntax: allow stmt/expr macro invocations to be delimited by [].

this is useful for macros like vec! which construct containers
This commit is contained in:
Gábor Lehel
2014-03-16 22:46:04 +01:00
committed by Sean McArthur
parent b8ef9fd9c9
commit be673e77e7
3 changed files with 45 additions and 34 deletions

View File

@@ -297,21 +297,17 @@ pub fn can_begin_expr(t: &Token) -> bool {
}
}
/// what's the opposite delimiter?
pub fn flip_delimiter(t: &token::Token) -> token::Token {
/// Returns the matching close delimiter if this is an open delimiter,
/// otherwise `None`.
pub fn close_delimiter_for(t: &Token) -> Option<Token> {
match *t {
LPAREN => RPAREN,
LBRACE => RBRACE,
LBRACKET => RBRACKET,
RPAREN => LPAREN,
RBRACE => LBRACE,
RBRACKET => LBRACKET,
_ => fail!()
LPAREN => Some(RPAREN),
LBRACE => Some(RBRACE),
LBRACKET => Some(RBRACKET),
_ => None
}
}
pub fn is_lit(t: &Token) -> bool {
match *t {
LIT_CHAR(_) => true,