From 049c9b60fb0c59625a37b0349aa27acaa3cf884a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 2 Feb 2018 23:30:17 +0300 Subject: L: const & static keywords --- grammar.ron | 4 +++- src/syntax_kinds.rs | 6 ++++++ tests/data/lexer/0011_keywords.rs | 3 ++- 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( "loop", "while", "if", - "match" + "match", + "const", + "static", ], tokens: [ "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 { WHILE_KW, IF_KW, MATCH_KW, + CONST_KW, + STATIC_KW, ERROR, IDENT, UNDERSCORE, @@ -137,6 +139,8 @@ impl SyntaxKind { WHILE_KW => &SyntaxInfo { name: "WHILE_KW" }, IF_KW => &SyntaxInfo { name: "IF_KW" }, MATCH_KW => &SyntaxInfo { name: "MATCH_KW" }, + CONST_KW => &SyntaxInfo { name: "CONST_KW" }, + STATIC_KW => &SyntaxInfo { name: "STATIC_KW" }, ERROR => &SyntaxInfo { name: "ERROR" }, IDENT => &SyntaxInfo { name: "IDENT" }, UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" }, @@ -242,6 +246,8 @@ pub(crate) fn ident_to_keyword(ident: &str) -> Option { "while" => Some(WHILE_KW), "if" => Some(IF_KW), "match" => Some(MATCH_KW), + "const" => Some(CONST_KW), + "static" => Some(STATIC_KW), _ => None, } } 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 @@ -fn use struct trait enum impl true false as extern crate mod pub self super in where for loop while if match +fn use struct trait enum impl true false as extern crate +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 " " EXTERN_KW 6 "extern" WHITESPACE 1 " " CRATE_KW 5 "crate" -WHITESPACE 1 " " +WHITESPACE 1 "\n" MOD_KW 3 "mod" WHITESPACE 1 " " PUB_KW 3 "pub" @@ -41,4 +41,8 @@ WHITESPACE 1 " " IF_KW 2 "if" WHITESPACE 1 " " MATCH_KW 5 "match" +WHITESPACE 1 " " +CONST_KW 5 "const" +WHITESPACE 1 " " +STATIC_KW 6 "static" WHITESPACE 1 "\n" -- cgit v1.2.3