Use common variants for open and close delimiters

This common representation for delimeters should make pattern matching easier. Having a separate `token::DelimToken` enum also allows us to enforce the invariant that the opening and closing delimiters must be the same in `ast::TtDelimited`, removing the need to ensure matched delimiters when working with token trees.
This commit is contained in:
Brendan Zabarauskas
2014-10-29 21:37:54 +11:00
parent 77f44d4a7b
commit 936d999b52
17 changed files with 326 additions and 313 deletions

View File

@@ -97,8 +97,8 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
// miscellaneous, no highlighting
token::Dot | token::DotDot | token::DotDotDot | token::Comma | token::Semi |
token::Colon | token::ModSep | token::LArrow | token::LParen |
token::RParen | token::LBracket | token::LBrace | token::RBrace |
token::Colon | token::ModSep | token::LArrow | token::OpenDelim(_) |
token::CloseDelim(token::Brace) | token::CloseDelim(token::Paren) |
token::Question => "",
token::Dollar => {
if lexer.peek().tok.is_ident() {
@@ -118,7 +118,7 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
try!(write!(out, r"<span class='attribute'>#"));
continue
}
token::RBracket => {
token::CloseDelim(token::Bracket) => {
if is_attribute {
is_attribute = false;
try!(write!(out, "]</span>"));