Add raw idents to lexer and parser

This commit is contained in:
Josh Robson Chase 2019-01-23 12:15:47 -05:00
parent 0b942cbcb0
commit 1cd6d6539a
26 changed files with 124 additions and 40 deletions

View file

@ -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) {