diff options
author | Aleksey Kladov <[email protected]> | 2018-02-02 20:30:17 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-02-02 20:30:17 +0000 |
commit | 049c9b60fb0c59625a37b0349aa27acaa3cf884a (patch) | |
tree | ee5b41eeba4c1e4debac89f18b7f424b958ff12d | |
parent | f9ecc680f0317bc56e661d7b41e7edcf52b2f995 (diff) |
L: const & static keywords
-rw-r--r-- | grammar.ron | 4 | ||||
-rw-r--r-- | src/syntax_kinds.rs | 6 | ||||
-rw-r--r-- | tests/data/lexer/0011_keywords.rs | 3 | ||||
-rw-r--r-- | tests/data/lexer/0011_keywords.txt | 6 |
4 files changed, 16 insertions, 3 deletions
diff --git a/grammar.ron b/grammar.ron index 44826c779..e7acd3cb0 100644 --- a/grammar.ron +++ b/grammar.ron | |||
@@ -21,7 +21,9 @@ Grammar( | |||
21 | "loop", | 21 | "loop", |
22 | "while", | 22 | "while", |
23 | "if", | 23 | "if", |
24 | "match" | 24 | "match", |
25 | "const", | ||
26 | "static", | ||
25 | ], | 27 | ], |
26 | tokens: [ | 28 | tokens: [ |
27 | "ERROR", | 29 | "ERROR", |
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index 7577fa037..f5d01c6f3 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs | |||
@@ -28,6 +28,8 @@ pub enum SyntaxKind { | |||
28 | WHILE_KW, | 28 | WHILE_KW, |
29 | IF_KW, | 29 | IF_KW, |
30 | MATCH_KW, | 30 | MATCH_KW, |
31 | CONST_KW, | ||
32 | STATIC_KW, | ||
31 | ERROR, | 33 | ERROR, |
32 | IDENT, | 34 | IDENT, |
33 | UNDERSCORE, | 35 | UNDERSCORE, |
@@ -137,6 +139,8 @@ impl SyntaxKind { | |||
137 | WHILE_KW => &SyntaxInfo { name: "WHILE_KW" }, | 139 | WHILE_KW => &SyntaxInfo { name: "WHILE_KW" }, |
138 | IF_KW => &SyntaxInfo { name: "IF_KW" }, | 140 | IF_KW => &SyntaxInfo { name: "IF_KW" }, |
139 | MATCH_KW => &SyntaxInfo { name: "MATCH_KW" }, | 141 | MATCH_KW => &SyntaxInfo { name: "MATCH_KW" }, |
142 | CONST_KW => &SyntaxInfo { name: "CONST_KW" }, | ||
143 | STATIC_KW => &SyntaxInfo { name: "STATIC_KW" }, | ||
140 | ERROR => &SyntaxInfo { name: "ERROR" }, | 144 | ERROR => &SyntaxInfo { name: "ERROR" }, |
141 | IDENT => &SyntaxInfo { name: "IDENT" }, | 145 | IDENT => &SyntaxInfo { name: "IDENT" }, |
142 | UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" }, | 146 | UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" }, |
@@ -242,6 +246,8 @@ pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> { | |||
242 | "while" => Some(WHILE_KW), | 246 | "while" => Some(WHILE_KW), |
243 | "if" => Some(IF_KW), | 247 | "if" => Some(IF_KW), |
244 | "match" => Some(MATCH_KW), | 248 | "match" => Some(MATCH_KW), |
249 | "const" => Some(CONST_KW), | ||
250 | "static" => Some(STATIC_KW), | ||
245 | _ => None, | 251 | _ => None, |
246 | } | 252 | } |
247 | } | 253 | } |
diff --git a/tests/data/lexer/0011_keywords.rs b/tests/data/lexer/0011_keywords.rs index 02ca19089..7a1000bb7 100644 --- a/tests/data/lexer/0011_keywords.rs +++ b/tests/data/lexer/0011_keywords.rs | |||
@@ -1 +1,2 @@ | |||
1 | fn use struct trait enum impl true false as extern crate mod pub self super in where for loop while if match | 1 | fn use struct trait enum impl true false as extern crate |
2 | mod pub self super in where for loop while if match const static | ||
diff --git a/tests/data/lexer/0011_keywords.txt b/tests/data/lexer/0011_keywords.txt index 964e3475a..b38b4bd64 100644 --- a/tests/data/lexer/0011_keywords.txt +++ b/tests/data/lexer/0011_keywords.txt | |||
@@ -19,7 +19,7 @@ WHITESPACE 1 " " | |||
19 | EXTERN_KW 6 "extern" | 19 | EXTERN_KW 6 "extern" |
20 | WHITESPACE 1 " " | 20 | WHITESPACE 1 " " |
21 | CRATE_KW 5 "crate" | 21 | CRATE_KW 5 "crate" |
22 | WHITESPACE 1 " " | 22 | WHITESPACE 1 "\n" |
23 | MOD_KW 3 "mod" | 23 | MOD_KW 3 "mod" |
24 | WHITESPACE 1 " " | 24 | WHITESPACE 1 " " |
25 | PUB_KW 3 "pub" | 25 | PUB_KW 3 "pub" |
@@ -41,4 +41,8 @@ WHITESPACE 1 " " | |||
41 | IF_KW 2 "if" | 41 | IF_KW 2 "if" |
42 | WHITESPACE 1 " " | 42 | WHITESPACE 1 " " |
43 | MATCH_KW 5 "match" | 43 | MATCH_KW 5 "match" |
44 | WHITESPACE 1 " " | ||
45 | CONST_KW 5 "const" | ||
46 | WHITESPACE 1 " " | ||
47 | STATIC_KW 6 "static" | ||
44 | WHITESPACE 1 "\n" | 48 | WHITESPACE 1 "\n" |