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:
committed by
Sean McArthur
parent
b8ef9fd9c9
commit
be673e77e7
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user