From 412948c0e2f34b1db13201bf533468241ee881e6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 30 Dec 2017 18:25:37 +0300 Subject: More symbols --- src/lexer/mod.rs | 20 ++++++++++++++++++++ src/syntax_kinds.rs | 12 +++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index d2d4aaa22..5255c3d56 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -52,6 +52,8 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { '~' => return TILDE, '?' => return QUESTION, '$' => return DOLLAR, + + // Multi-byte tokens. '.' => return match (ptr.next(), ptr.nnext()) { (Some('.'), Some('.')) => { ptr.bump(); @@ -76,6 +78,24 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { } _ => 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 diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index 6982cba95..a922056ce 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs @@ -26,8 +26,13 @@ pub const QUESTION: SyntaxKind = SyntaxKind(21); pub const COLON: SyntaxKind = SyntaxKind(22); pub const COLONCOLON: SyntaxKind = SyntaxKind(23); 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: "IDENT" }, SyntaxInfo { name: "UNDERSCORE" }, @@ -53,6 +58,11 @@ static INFOS: [SyntaxInfo; 25] = [ SyntaxInfo { name: "COLON" }, SyntaxInfo { name: "COLONCOLON" }, 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 { -- cgit v1.2.3