syntax: Make is_path_start precise and improve some error messages about unexpected tokens

This commit is contained in:
Vadim Petrochenkov 2016-04-21 02:03:29 +03:00
parent 6c44bea644
commit a97f60ee86
25 changed files with 88 additions and 73 deletions

View file

@ -243,6 +243,11 @@ impl Token {
self.is_keyword(keywords::Const)
}
pub fn is_path_start(&self) -> bool {
self == &ModSep || self == &Lt || self.is_path() ||
self.is_path_segment_keyword() || self.is_ident() && !self.is_any_keyword()
}
/// Maps a token to its corresponding binary operator.
pub fn to_binop(&self) -> Option<BinOpKind> {
match *self {