libsyntax: parse inclusive ranges
This commit is contained in:
parent
c5d58de665
commit
5daf13cae3
7 changed files with 81 additions and 50 deletions
|
@ -61,6 +61,8 @@ pub enum AssocOp {
|
|||
As,
|
||||
/// `..` range
|
||||
DotDot,
|
||||
/// `...` range
|
||||
DotDotDot,
|
||||
/// `:`
|
||||
Colon,
|
||||
}
|
||||
|
@ -102,6 +104,7 @@ impl AssocOp {
|
|||
Token::AndAnd => Some(LAnd),
|
||||
Token::OrOr => Some(LOr),
|
||||
Token::DotDot => Some(DotDot),
|
||||
Token::DotDotDot => Some(DotDotDot),
|
||||
Token::Colon => Some(Colon),
|
||||
_ if t.is_keyword(keywords::As) => Some(As),
|
||||
_ => None
|
||||
|
@ -147,7 +150,7 @@ impl AssocOp {
|
|||
Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual => 7,
|
||||
LAnd => 6,
|
||||
LOr => 5,
|
||||
DotDot => 4,
|
||||
DotDot | DotDotDot => 4,
|
||||
Inplace => 3,
|
||||
Assign | AssignOp(_) => 2,
|
||||
}
|
||||
|
@ -162,7 +165,7 @@ impl AssocOp {
|
|||
As | Multiply | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd |
|
||||
BitXor | BitOr | Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual |
|
||||
LAnd | LOr | Colon => Fixity::Left,
|
||||
DotDot => Fixity::None
|
||||
DotDot | DotDotDot => Fixity::None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +174,8 @@ impl AssocOp {
|
|||
match *self {
|
||||
Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual => true,
|
||||
Inplace | Assign | AssignOp(_) | As | Multiply | Divide | Modulus | Add | Subtract |
|
||||
ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd | LOr | DotDot | Colon => false
|
||||
ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd | LOr |
|
||||
DotDot | DotDotDot | Colon => false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +185,7 @@ impl AssocOp {
|
|||
Assign | AssignOp(_) | Inplace => true,
|
||||
Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual | As | Multiply | Divide |
|
||||
Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd |
|
||||
LOr | DotDot | Colon => false
|
||||
LOr | DotDot | DotDotDot | Colon => false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +210,7 @@ impl AssocOp {
|
|||
BitOr => Some(BinOpKind::BitOr),
|
||||
LAnd => Some(BinOpKind::And),
|
||||
LOr => Some(BinOpKind::Or),
|
||||
Inplace | Assign | AssignOp(_) | As | DotDot | Colon => None
|
||||
Inplace | Assign | AssignOp(_) | As | DotDot | DotDotDot | Colon => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue