From 8103772a10f00378c4dcdd09f9af310c23146933 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 30 Dec 2017 01:01:57 +0300 Subject: Lexer: underscore --- src/lexer/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/lexer') diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index ecea664da..83a411cdd 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -22,6 +22,14 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { // They are not identifiers, and are handled further down. let ident_start = is_ident_start(c) && !string_literal_start(c, ptr.next(), ptr.nnext()); if ident_start { + let is_single_letter = match ptr.next() { + None => true, + Some(c) if !is_ident_continue(c) => true, + _ => false, + }; + if is_single_letter { + return if c == '_' { UNDERSCORE } else { IDENT }; + } ptr.bump_while(is_ident_continue); return IDENT; } -- cgit v1.2.3