mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Add raw idents to lexer and parser
This commit is contained in:
parent
0b942cbcb0
commit
1cd6d6539a
26 changed files with 124 additions and 40 deletions
|
@ -190,19 +190,24 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
|
|||
}
|
||||
|
||||
fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind {
|
||||
let is_single_letter = match ptr.current() {
|
||||
None => true,
|
||||
Some(c) if !is_ident_continue(c) => true,
|
||||
let is_raw = match (c, ptr.current()) {
|
||||
('r', Some('#')) => {
|
||||
ptr.bump();
|
||||
true
|
||||
}
|
||||
('_', Some(c)) if !is_ident_continue(c) => return UNDERSCORE,
|
||||
_ => false,
|
||||
};
|
||||
if is_single_letter {
|
||||
return if c == '_' { UNDERSCORE } else { IDENT };
|
||||
}
|
||||
|
||||
ptr.bump_while(is_ident_continue);
|
||||
if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) {
|
||||
|
||||
if is_raw {
|
||||
RAW_IDENT
|
||||
} else if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) {
|
||||
return kind;
|
||||
} else {
|
||||
IDENT
|
||||
}
|
||||
IDENT
|
||||
}
|
||||
|
||||
fn scan_literal_suffix(ptr: &mut Ptr) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue