aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grammar.ron5
-rw-r--r--src/lexer/mod.rs20
-rw-r--r--src/syntax_kinds.rs12
-rw-r--r--tests/data/lexer/0005_symbols.rs4
-rw-r--r--tests/data/lexer/0005_symbols.txt8
5 files changed, 47 insertions, 2 deletions
diff --git a/grammar.ron b/grammar.ron
index 56617f757..4c9291dfb 100644
--- a/grammar.ron
+++ b/grammar.ron
@@ -25,5 +25,10 @@ Grammar(
25 "COLON", 25 "COLON",
26 "COLONCOLON", 26 "COLONCOLON",
27 "DOLLAR", 27 "DOLLAR",
28 "EQ",
29 "EQEQ",
30 "FAT_ARROW",
31 "NEQ",
32 "NOT",
28 ] 33 ]
29) \ No newline at end of file 34) \ No newline at end of file
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 {
52 '~' => return TILDE, 52 '~' => return TILDE,
53 '?' => return QUESTION, 53 '?' => return QUESTION,
54 '$' => return DOLLAR, 54 '$' => return DOLLAR,
55
56 // Multi-byte tokens.
55 '.' => return match (ptr.next(), ptr.nnext()) { 57 '.' => return match (ptr.next(), ptr.nnext()) {
56 (Some('.'), Some('.')) => { 58 (Some('.'), Some('.')) => {
57 ptr.bump(); 59 ptr.bump();
@@ -76,6 +78,24 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
76 } 78 }
77 _ => COLON 79 _ => COLON
78 }, 80 },
81 '=' => return match ptr.next() {
82 Some('=') => {
83 ptr.bump();
84 EQEQ
85 }
86 Some('>') => {
87 ptr.bump();
88 FAT_ARROW
89 }
90 _ => EQ,
91 },
92 '!' => return match ptr.next() {
93 Some('=') => {
94 ptr.bump();
95 NEQ
96 }
97 _ => NOT,
98 },
79 _ => (), 99 _ => (),
80 } 100 }
81 ERROR 101 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);
26pub const COLON: SyntaxKind = SyntaxKind(22); 26pub const COLON: SyntaxKind = SyntaxKind(22);
27pub const COLONCOLON: SyntaxKind = SyntaxKind(23); 27pub const COLONCOLON: SyntaxKind = SyntaxKind(23);
28pub const DOLLAR: SyntaxKind = SyntaxKind(24); 28pub const DOLLAR: SyntaxKind = SyntaxKind(24);
29pub const EQ: SyntaxKind = SyntaxKind(25);
30pub const EQEQ: SyntaxKind = SyntaxKind(26);
31pub const FAT_ARROW: SyntaxKind = SyntaxKind(27);
32pub const NEQ: SyntaxKind = SyntaxKind(28);
33pub const NOT: SyntaxKind = SyntaxKind(29);
29 34
30static INFOS: [SyntaxInfo; 25] = [ 35static INFOS: [SyntaxInfo; 30] = [
31 SyntaxInfo { name: "ERROR" }, 36 SyntaxInfo { name: "ERROR" },
32 SyntaxInfo { name: "IDENT" }, 37 SyntaxInfo { name: "IDENT" },
33 SyntaxInfo { name: "UNDERSCORE" }, 38 SyntaxInfo { name: "UNDERSCORE" },
@@ -53,6 +58,11 @@ static INFOS: [SyntaxInfo; 25] = [
53 SyntaxInfo { name: "COLON" }, 58 SyntaxInfo { name: "COLON" },
54 SyntaxInfo { name: "COLONCOLON" }, 59 SyntaxInfo { name: "COLONCOLON" },
55 SyntaxInfo { name: "DOLLAR" }, 60 SyntaxInfo { name: "DOLLAR" },
61 SyntaxInfo { name: "EQ" },
62 SyntaxInfo { name: "EQEQ" },
63 SyntaxInfo { name: "FAT_ARROW" },
64 SyntaxInfo { name: "NEQ" },
65 SyntaxInfo { name: "NOT" },
56]; 66];
57 67
58pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo { 68pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo {
diff --git a/tests/data/lexer/0005_symbols.rs b/tests/data/lexer/0005_symbols.rs
index 79747d5e1..00ed44b65 100644
--- a/tests/data/lexer/0005_symbols.rs
+++ b/tests/data/lexer/0005_symbols.rs
@@ -1,3 +1,5 @@
1; , ( ) { } [ ] @ # ~ ? $ 1; , ( ) { } [ ] @ # ~ ? $
2. .. ... ..= 2. .. ... ..=
3: :: \ No newline at end of file 3: ::
4= =>
5! != \ No newline at end of file
diff --git a/tests/data/lexer/0005_symbols.txt b/tests/data/lexer/0005_symbols.txt
index c845d2dff..291872026 100644
--- a/tests/data/lexer/0005_symbols.txt
+++ b/tests/data/lexer/0005_symbols.txt
@@ -35,3 +35,11 @@ WHITESPACE 1 "\n"
35COLON 1 ":" 35COLON 1 ":"
36WHITESPACE 1 " " 36WHITESPACE 1 " "
37COLONCOLON 2 "::" 37COLONCOLON 2 "::"
38WHITESPACE 1 "\n"
39EQ 1 "="
40WHITESPACE 1 " "
41FAT_ARROW 2 "=>"
42WHITESPACE 1 "\n"
43NOT 1 "!"
44WHITESPACE 1 " "
45NEQ 2 "!="