mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
More symbols
This commit is contained in:
parent
fad3e50987
commit
412948c0e2
5 changed files with 47 additions and 2 deletions
|
@ -25,5 +25,10 @@ Grammar(
|
||||||
"COLON",
|
"COLON",
|
||||||
"COLONCOLON",
|
"COLONCOLON",
|
||||||
"DOLLAR",
|
"DOLLAR",
|
||||||
|
"EQ",
|
||||||
|
"EQEQ",
|
||||||
|
"FAT_ARROW",
|
||||||
|
"NEQ",
|
||||||
|
"NOT",
|
||||||
]
|
]
|
||||||
)
|
)
|
|
@ -52,6 +52,8 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
|
||||||
'~' => return TILDE,
|
'~' => return TILDE,
|
||||||
'?' => return QUESTION,
|
'?' => return QUESTION,
|
||||||
'$' => return DOLLAR,
|
'$' => return DOLLAR,
|
||||||
|
|
||||||
|
// Multi-byte tokens.
|
||||||
'.' => return match (ptr.next(), ptr.nnext()) {
|
'.' => return match (ptr.next(), ptr.nnext()) {
|
||||||
(Some('.'), Some('.')) => {
|
(Some('.'), Some('.')) => {
|
||||||
ptr.bump();
|
ptr.bump();
|
||||||
|
@ -76,6 +78,24 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
|
||||||
}
|
}
|
||||||
_ => COLON
|
_ => COLON
|
||||||
},
|
},
|
||||||
|
'=' => return match ptr.next() {
|
||||||
|
Some('=') => {
|
||||||
|
ptr.bump();
|
||||||
|
EQEQ
|
||||||
|
}
|
||||||
|
Some('>') => {
|
||||||
|
ptr.bump();
|
||||||
|
FAT_ARROW
|
||||||
|
}
|
||||||
|
_ => EQ,
|
||||||
|
},
|
||||||
|
'!' => return match ptr.next() {
|
||||||
|
Some('=') => {
|
||||||
|
ptr.bump();
|
||||||
|
NEQ
|
||||||
|
}
|
||||||
|
_ => NOT,
|
||||||
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
ERROR
|
ERROR
|
||||||
|
|
|
@ -26,8 +26,13 @@ pub const QUESTION: SyntaxKind = SyntaxKind(21);
|
||||||
pub const COLON: SyntaxKind = SyntaxKind(22);
|
pub const COLON: SyntaxKind = SyntaxKind(22);
|
||||||
pub const COLONCOLON: SyntaxKind = SyntaxKind(23);
|
pub const COLONCOLON: SyntaxKind = SyntaxKind(23);
|
||||||
pub const DOLLAR: SyntaxKind = SyntaxKind(24);
|
pub const DOLLAR: SyntaxKind = SyntaxKind(24);
|
||||||
|
pub const EQ: SyntaxKind = SyntaxKind(25);
|
||||||
|
pub const EQEQ: SyntaxKind = SyntaxKind(26);
|
||||||
|
pub const FAT_ARROW: SyntaxKind = SyntaxKind(27);
|
||||||
|
pub const NEQ: SyntaxKind = SyntaxKind(28);
|
||||||
|
pub const NOT: SyntaxKind = SyntaxKind(29);
|
||||||
|
|
||||||
static INFOS: [SyntaxInfo; 25] = [
|
static INFOS: [SyntaxInfo; 30] = [
|
||||||
SyntaxInfo { name: "ERROR" },
|
SyntaxInfo { name: "ERROR" },
|
||||||
SyntaxInfo { name: "IDENT" },
|
SyntaxInfo { name: "IDENT" },
|
||||||
SyntaxInfo { name: "UNDERSCORE" },
|
SyntaxInfo { name: "UNDERSCORE" },
|
||||||
|
@ -53,6 +58,11 @@ static INFOS: [SyntaxInfo; 25] = [
|
||||||
SyntaxInfo { name: "COLON" },
|
SyntaxInfo { name: "COLON" },
|
||||||
SyntaxInfo { name: "COLONCOLON" },
|
SyntaxInfo { name: "COLONCOLON" },
|
||||||
SyntaxInfo { name: "DOLLAR" },
|
SyntaxInfo { name: "DOLLAR" },
|
||||||
|
SyntaxInfo { name: "EQ" },
|
||||||
|
SyntaxInfo { name: "EQEQ" },
|
||||||
|
SyntaxInfo { name: "FAT_ARROW" },
|
||||||
|
SyntaxInfo { name: "NEQ" },
|
||||||
|
SyntaxInfo { name: "NOT" },
|
||||||
];
|
];
|
||||||
|
|
||||||
pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo {
|
pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
; , ( ) { } [ ] @ # ~ ? $
|
; , ( ) { } [ ] @ # ~ ? $
|
||||||
. .. ... ..=
|
. .. ... ..=
|
||||||
: ::
|
: ::
|
||||||
|
= =>
|
||||||
|
! !=
|
|
@ -35,3 +35,11 @@ WHITESPACE 1 "\n"
|
||||||
COLON 1 ":"
|
COLON 1 ":"
|
||||||
WHITESPACE 1 " "
|
WHITESPACE 1 " "
|
||||||
COLONCOLON 2 "::"
|
COLONCOLON 2 "::"
|
||||||
|
WHITESPACE 1 "\n"
|
||||||
|
EQ 1 "="
|
||||||
|
WHITESPACE 1 " "
|
||||||
|
FAT_ARROW 2 "=>"
|
||||||
|
WHITESPACE 1 "\n"
|
||||||
|
NOT 1 "!"
|
||||||
|
WHITESPACE 1 " "
|
||||||
|
NEQ 2 "!="
|
||||||
|
|
Loading…
Reference in a new issue