aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-01-08 18:21:59 +0000
committerAleksey Kladov <[email protected]>2018-01-08 18:21:59 +0000
commitf25142c5edc579c7f7030c03c2673db238255bb2 (patch)
treec652b46e510f11b9c760fb8d94d31231d760c8a5
parent55027bed0867356a7c84ab2df3d6dcecc45e455d (diff)
L: true and false are keywords
-rw-r--r--grammar.ron2
-rw-r--r--src/syntax_kinds.rs122
-rw-r--r--tests/data/lexer/0011_keywords.rs2
-rw-r--r--tests/data/lexer/0011_keywords.txt4
-rw-r--r--tests/data/parser/ok/0006_inner_attributes.txt58
5 files changed, 96 insertions, 92 deletions
diff --git a/grammar.ron b/grammar.ron
index e3b450d2b..0d180e19c 100644
--- a/grammar.ron
+++ b/grammar.ron
@@ -6,6 +6,8 @@ Grammar(
6 "enum", 6 "enum",
7 "trait", 7 "trait",
8 "impl", 8 "impl",
9 "true",
10 "false",
9 ], 11 ],
10 tokens: [ 12 tokens: [
11 "ERROR", 13 "ERROR",
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index eea7819a3..53ea0775a 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -7,71 +7,75 @@ pub const STRUCT_KW: SyntaxKind = SyntaxKind(2);
7pub const ENUM_KW: SyntaxKind = SyntaxKind(3); 7pub const ENUM_KW: SyntaxKind = SyntaxKind(3);
8pub const TRAIT_KW: SyntaxKind = SyntaxKind(4); 8pub const TRAIT_KW: SyntaxKind = SyntaxKind(4);
9pub const IMPL_KW: SyntaxKind = SyntaxKind(5); 9pub const IMPL_KW: SyntaxKind = SyntaxKind(5);
10pub const ERROR: SyntaxKind = SyntaxKind(6); 10pub const TRUE_KW: SyntaxKind = SyntaxKind(6);
11pub const IDENT: SyntaxKind = SyntaxKind(7); 11pub const FALSE_KW: SyntaxKind = SyntaxKind(7);
12pub const UNDERSCORE: SyntaxKind = SyntaxKind(8); 12pub const ERROR: SyntaxKind = SyntaxKind(8);
13pub const WHITESPACE: SyntaxKind = SyntaxKind(9); 13pub const IDENT: SyntaxKind = SyntaxKind(9);
14pub const INT_NUMBER: SyntaxKind = SyntaxKind(10); 14pub const UNDERSCORE: SyntaxKind = SyntaxKind(10);
15pub const FLOAT_NUMBER: SyntaxKind = SyntaxKind(11); 15pub const WHITESPACE: SyntaxKind = SyntaxKind(11);
16pub const SEMI: SyntaxKind = SyntaxKind(12); 16pub const INT_NUMBER: SyntaxKind = SyntaxKind(12);
17pub const COMMA: SyntaxKind = SyntaxKind(13); 17pub const FLOAT_NUMBER: SyntaxKind = SyntaxKind(13);
18pub const DOT: SyntaxKind = SyntaxKind(14); 18pub const SEMI: SyntaxKind = SyntaxKind(14);
19pub const DOTDOT: SyntaxKind = SyntaxKind(15); 19pub const COMMA: SyntaxKind = SyntaxKind(15);
20pub const DOTDOTDOT: SyntaxKind = SyntaxKind(16); 20pub const DOT: SyntaxKind = SyntaxKind(16);
21pub const DOTDOTEQ: SyntaxKind = SyntaxKind(17); 21pub const DOTDOT: SyntaxKind = SyntaxKind(17);
22pub const L_PAREN: SyntaxKind = SyntaxKind(18); 22pub const DOTDOTDOT: SyntaxKind = SyntaxKind(18);
23pub const R_PAREN: SyntaxKind = SyntaxKind(19); 23pub const DOTDOTEQ: SyntaxKind = SyntaxKind(19);
24pub const L_CURLY: SyntaxKind = SyntaxKind(20); 24pub const L_PAREN: SyntaxKind = SyntaxKind(20);
25pub const R_CURLY: SyntaxKind = SyntaxKind(21); 25pub const R_PAREN: SyntaxKind = SyntaxKind(21);
26pub const L_BRACK: SyntaxKind = SyntaxKind(22); 26pub const L_CURLY: SyntaxKind = SyntaxKind(22);
27pub const R_BRACK: SyntaxKind = SyntaxKind(23); 27pub const R_CURLY: SyntaxKind = SyntaxKind(23);
28pub const L_ANGLE: SyntaxKind = SyntaxKind(24); 28pub const L_BRACK: SyntaxKind = SyntaxKind(24);
29pub const R_ANGLE: SyntaxKind = SyntaxKind(25); 29pub const R_BRACK: SyntaxKind = SyntaxKind(25);
30pub const AT: SyntaxKind = SyntaxKind(26); 30pub const L_ANGLE: SyntaxKind = SyntaxKind(26);
31pub const POUND: SyntaxKind = SyntaxKind(27); 31pub const R_ANGLE: SyntaxKind = SyntaxKind(27);
32pub const TILDE: SyntaxKind = SyntaxKind(28); 32pub const AT: SyntaxKind = SyntaxKind(28);
33pub const QUESTION: SyntaxKind = SyntaxKind(29); 33pub const POUND: SyntaxKind = SyntaxKind(29);
34pub const COLON: SyntaxKind = SyntaxKind(30); 34pub const TILDE: SyntaxKind = SyntaxKind(30);
35pub const COLONCOLON: SyntaxKind = SyntaxKind(31); 35pub const QUESTION: SyntaxKind = SyntaxKind(31);
36pub const DOLLAR: SyntaxKind = SyntaxKind(32); 36pub const COLON: SyntaxKind = SyntaxKind(32);
37pub const EQ: SyntaxKind = SyntaxKind(33); 37pub const COLONCOLON: SyntaxKind = SyntaxKind(33);
38pub const EQEQ: SyntaxKind = SyntaxKind(34); 38pub const DOLLAR: SyntaxKind = SyntaxKind(34);
39pub const FAT_ARROW: SyntaxKind = SyntaxKind(35); 39pub const EQ: SyntaxKind = SyntaxKind(35);
40pub const NEQ: SyntaxKind = SyntaxKind(36); 40pub const EQEQ: SyntaxKind = SyntaxKind(36);
41pub const EXCL: SyntaxKind = SyntaxKind(37); 41pub const FAT_ARROW: SyntaxKind = SyntaxKind(37);
42pub const LIFETIME: SyntaxKind = SyntaxKind(38); 42pub const NEQ: SyntaxKind = SyntaxKind(38);
43pub const CHAR: SyntaxKind = SyntaxKind(39); 43pub const EXCL: SyntaxKind = SyntaxKind(39);
44pub const BYTE: SyntaxKind = SyntaxKind(40); 44pub const LIFETIME: SyntaxKind = SyntaxKind(40);
45pub const STRING: SyntaxKind = SyntaxKind(41); 45pub const CHAR: SyntaxKind = SyntaxKind(41);
46pub const RAW_STRING: SyntaxKind = SyntaxKind(42); 46pub const BYTE: SyntaxKind = SyntaxKind(42);
47pub const BYTE_STRING: SyntaxKind = SyntaxKind(43); 47pub const STRING: SyntaxKind = SyntaxKind(43);
48pub const RAW_BYTE_STRING: SyntaxKind = SyntaxKind(44); 48pub const RAW_STRING: SyntaxKind = SyntaxKind(44);
49pub const PLUS: SyntaxKind = SyntaxKind(45); 49pub const BYTE_STRING: SyntaxKind = SyntaxKind(45);
50pub const MINUS: SyntaxKind = SyntaxKind(46); 50pub const RAW_BYTE_STRING: SyntaxKind = SyntaxKind(46);
51pub const STAR: SyntaxKind = SyntaxKind(47); 51pub const PLUS: SyntaxKind = SyntaxKind(47);
52pub const SLASH: SyntaxKind = SyntaxKind(48); 52pub const MINUS: SyntaxKind = SyntaxKind(48);
53pub const CARET: SyntaxKind = SyntaxKind(49); 53pub const STAR: SyntaxKind = SyntaxKind(49);
54pub const PERCENT: SyntaxKind = SyntaxKind(50); 54pub const SLASH: SyntaxKind = SyntaxKind(50);
55pub const AMPERSAND: SyntaxKind = SyntaxKind(51); 55pub const CARET: SyntaxKind = SyntaxKind(51);
56pub const PIPE: SyntaxKind = SyntaxKind(52); 56pub const PERCENT: SyntaxKind = SyntaxKind(52);
57pub const THIN_ARROW: SyntaxKind = SyntaxKind(53); 57pub const AMPERSAND: SyntaxKind = SyntaxKind(53);
58pub const COMMENT: SyntaxKind = SyntaxKind(54); 58pub const PIPE: SyntaxKind = SyntaxKind(54);
59pub const DOC_COMMENT: SyntaxKind = SyntaxKind(55); 59pub const THIN_ARROW: SyntaxKind = SyntaxKind(55);
60pub const SHEBANG: SyntaxKind = SyntaxKind(56); 60pub const COMMENT: SyntaxKind = SyntaxKind(56);
61pub const FILE: SyntaxKind = SyntaxKind(57); 61pub const DOC_COMMENT: SyntaxKind = SyntaxKind(57);
62pub const STRUCT_ITEM: SyntaxKind = SyntaxKind(58); 62pub const SHEBANG: SyntaxKind = SyntaxKind(58);
63pub const STRUCT_FIELD: SyntaxKind = SyntaxKind(59); 63pub const FILE: SyntaxKind = SyntaxKind(59);
64pub const FN_ITEM: SyntaxKind = SyntaxKind(60); 64pub const STRUCT_ITEM: SyntaxKind = SyntaxKind(60);
65pub const ATTR: SyntaxKind = SyntaxKind(61); 65pub const STRUCT_FIELD: SyntaxKind = SyntaxKind(61);
66pub const META_ITEM: SyntaxKind = SyntaxKind(62); 66pub const FN_ITEM: SyntaxKind = SyntaxKind(62);
67pub const ATTR: SyntaxKind = SyntaxKind(63);
68pub const META_ITEM: SyntaxKind = SyntaxKind(64);
67 69
68static INFOS: [SyntaxInfo; 63] = [ 70static INFOS: [SyntaxInfo; 65] = [
69 SyntaxInfo { name: "USE_KW" }, 71 SyntaxInfo { name: "USE_KW" },
70 SyntaxInfo { name: "FN_KW" }, 72 SyntaxInfo { name: "FN_KW" },
71 SyntaxInfo { name: "STRUCT_KW" }, 73 SyntaxInfo { name: "STRUCT_KW" },
72 SyntaxInfo { name: "ENUM_KW" }, 74 SyntaxInfo { name: "ENUM_KW" },
73 SyntaxInfo { name: "TRAIT_KW" }, 75 SyntaxInfo { name: "TRAIT_KW" },
74 SyntaxInfo { name: "IMPL_KW" }, 76 SyntaxInfo { name: "IMPL_KW" },
77 SyntaxInfo { name: "TRUE_KW" },
78 SyntaxInfo { name: "FALSE_KW" },
75 SyntaxInfo { name: "ERROR" }, 79 SyntaxInfo { name: "ERROR" },
76 SyntaxInfo { name: "IDENT" }, 80 SyntaxInfo { name: "IDENT" },
77 SyntaxInfo { name: "UNDERSCORE" }, 81 SyntaxInfo { name: "UNDERSCORE" },
@@ -143,6 +147,8 @@ pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {
143 "enum" => Some(ENUM_KW), 147 "enum" => Some(ENUM_KW),
144 "trait" => Some(TRAIT_KW), 148 "trait" => Some(TRAIT_KW),
145 "impl" => Some(IMPL_KW), 149 "impl" => Some(IMPL_KW),
150 "true" => Some(TRUE_KW),
151 "false" => Some(FALSE_KW),
146 _ => None, 152 _ => None,
147 } 153 }
148} 154}
diff --git a/tests/data/lexer/0011_keywords.rs b/tests/data/lexer/0011_keywords.rs
index aa89d70c5..1f4a4a74c 100644
--- a/tests/data/lexer/0011_keywords.rs
+++ b/tests/data/lexer/0011_keywords.rs
@@ -1 +1 @@
fn use struct trait enum impl fn use struct trait enum impl true false
diff --git a/tests/data/lexer/0011_keywords.txt b/tests/data/lexer/0011_keywords.txt
index d90047d1e..eded37084 100644
--- a/tests/data/lexer/0011_keywords.txt
+++ b/tests/data/lexer/0011_keywords.txt
@@ -9,4 +9,8 @@ WHITESPACE 1 " "
9ENUM_KW 4 "enum" 9ENUM_KW 4 "enum"
10WHITESPACE 1 " " 10WHITESPACE 1 " "
11IMPL_KW 4 "impl" 11IMPL_KW 4 "impl"
12WHITESPACE 1 " "
13TRUE_KW 4 "true"
14WHITESPACE 1 " "
15FALSE_KW 5 "false"
12WHITESPACE 1 "\n" 16WHITESPACE 1 "\n"
diff --git a/tests/data/parser/ok/0006_inner_attributes.txt b/tests/data/parser/ok/0006_inner_attributes.txt
index a19d2f49c..5d27a015b 100644
--- a/tests/data/parser/ok/0006_inner_attributes.txt
+++ b/tests/data/parser/ok/0006_inner_attributes.txt
@@ -7,52 +7,44 @@ FILE@[0; 236)
7 IDENT@[3; 7) 7 IDENT@[3; 7)
8 R_BRACK@[7; 8) 8 R_BRACK@[7; 8)
9 WHITESPACE@[8; 9) 9 WHITESPACE@[8; 9)
10 ATTR@[9; 24) 10 ATTR@[9; 17)
11 POUND@[9; 10) 11 POUND@[9; 10)
12 EXCL@[10; 11) 12 EXCL@[10; 11)
13 L_BRACK@[11; 12) 13 L_BRACK@[11; 12)
14 META_ITEM@[12; 22) 14 META_ITEM@[12; 17)
15 IDENT@[12; 16) 15 IDENT@[12; 16)
16 L_PAREN@[16; 17) 16 L_PAREN@[16; 17)
17 META_ITEM@[17; 21) 17 err: `expected R_PAREN`
18 IDENT@[17; 21) 18 err: `expected R_BRACK`
19 R_PAREN@[21; 22) 19 ERROR@[17; 236)
20 err: `expected item`
21 TRUE_KW@[17; 21)
22 R_PAREN@[21; 22)
20 R_BRACK@[22; 23) 23 R_BRACK@[22; 23)
21 WHITESPACE@[23; 24) 24 WHITESPACE@[23; 24)
22 ATTR@[24; 40)
23 POUND@[24; 25) 25 POUND@[24; 25)
24 EXCL@[25; 26) 26 EXCL@[25; 26)
25 L_BRACK@[26; 27) 27 L_BRACK@[26; 27)
26 META_ITEM@[27; 38) 28 IDENT@[27; 31)
27 IDENT@[27; 31) 29 L_PAREN@[31; 32)
28 L_PAREN@[31; 32) 30 IDENT@[32; 37)
29 META_ITEM@[32; 37) 31 R_PAREN@[37; 38)
30 IDENT@[32; 37)
31 R_PAREN@[37; 38)
32 R_BRACK@[38; 39) 32 R_BRACK@[38; 39)
33 WHITESPACE@[39; 40) 33 WHITESPACE@[39; 40)
34 ATTR@[40; 66)
35 POUND@[40; 41) 34 POUND@[40; 41)
36 EXCL@[41; 42) 35 EXCL@[41; 42)
37 L_BRACK@[42; 43) 36 L_BRACK@[42; 43)
38 META_ITEM@[43; 66) 37 IDENT@[43; 47)
39 IDENT@[43; 47) 38 L_PAREN@[47; 48)
40 L_PAREN@[47; 48) 39 IDENT@[48; 53)
41 META_ITEM@[48; 53) 40 COMMA@[53; 54)
42 IDENT@[48; 53) 41 WHITESPACE@[54; 55)
43 COMMA@[53; 54) 42 INT_NUMBER@[55; 58)
44 WHITESPACE@[54; 55) 43 COMMA@[58; 59)
45 INT_NUMBER@[55; 58) 44 WHITESPACE@[59; 60)
46 COMMA@[58; 59) 45 TRUE_KW@[60; 64)
47 META_ITEM@[59; 64) 46 COMMA@[64; 65)
48 WHITESPACE@[59; 60) 47 WHITESPACE@[65; 66)
49 IDENT@[60; 64)
50 COMMA@[64; 65)
51 err: `expected R_PAREN`
52 WHITESPACE@[65; 66)
53 err: `expected R_BRACK`
54 ERROR@[66; 236)
55 err: `expected item`
56 STRING@[66; 72) 48 STRING@[66; 72)
57 COMMA@[72; 73) 49 COMMA@[72; 73)
58 WHITESPACE@[73; 74) 50 WHITESPACE@[73; 74)
@@ -95,7 +87,7 @@ FILE@[0; 236)
95 WHITESPACE@[146; 147) 87 WHITESPACE@[146; 147)
96 EQ@[147; 148) 88 EQ@[147; 148)
97 WHITESPACE@[148; 149) 89 WHITESPACE@[148; 149)
98 IDENT@[149; 153) 90 TRUE_KW@[149; 153)
99 R_PAREN@[153; 154) 91 R_PAREN@[153; 154)
100 R_BRACK@[154; 155) 92 R_BRACK@[154; 155)
101 WHITESPACE@[155; 156) 93 WHITESPACE@[155; 156)
@@ -104,7 +96,7 @@ FILE@[0; 236)
104 L_BRACK@[158; 159) 96 L_BRACK@[158; 159)
105 IDENT@[159; 166) 97 IDENT@[159; 166)
106 L_PAREN@[166; 167) 98 L_PAREN@[166; 167)
107 IDENT@[167; 171) 99 TRUE_KW@[167; 171)
108 R_PAREN@[171; 172) 100 R_PAREN@[171; 172)
109 R_BRACK@[172; 173) 101 R_BRACK@[172; 173)
110 WHITESPACE@[173; 174) 102 WHITESPACE@[173; 174)