L: true and false are keywords

This commit is contained in:
Aleksey Kladov 2018-01-08 21:21:59 +03:00
parent 55027bed08
commit f25142c5ed
5 changed files with 96 additions and 92 deletions

View file

@ -6,6 +6,8 @@ Grammar(
"enum",
"trait",
"impl",
"true",
"false",
],
tokens: [
"ERROR",

View file

@ -7,71 +7,75 @@ pub const STRUCT_KW: SyntaxKind = SyntaxKind(2);
pub const ENUM_KW: SyntaxKind = SyntaxKind(3);
pub const TRAIT_KW: SyntaxKind = SyntaxKind(4);
pub const IMPL_KW: SyntaxKind = SyntaxKind(5);
pub const ERROR: SyntaxKind = SyntaxKind(6);
pub const IDENT: SyntaxKind = SyntaxKind(7);
pub const UNDERSCORE: SyntaxKind = SyntaxKind(8);
pub const WHITESPACE: SyntaxKind = SyntaxKind(9);
pub const INT_NUMBER: SyntaxKind = SyntaxKind(10);
pub const FLOAT_NUMBER: SyntaxKind = SyntaxKind(11);
pub const SEMI: SyntaxKind = SyntaxKind(12);
pub const COMMA: SyntaxKind = SyntaxKind(13);
pub const DOT: SyntaxKind = SyntaxKind(14);
pub const DOTDOT: SyntaxKind = SyntaxKind(15);
pub const DOTDOTDOT: SyntaxKind = SyntaxKind(16);
pub const DOTDOTEQ: SyntaxKind = SyntaxKind(17);
pub const L_PAREN: SyntaxKind = SyntaxKind(18);
pub const R_PAREN: SyntaxKind = SyntaxKind(19);
pub const L_CURLY: SyntaxKind = SyntaxKind(20);
pub const R_CURLY: SyntaxKind = SyntaxKind(21);
pub const L_BRACK: SyntaxKind = SyntaxKind(22);
pub const R_BRACK: SyntaxKind = SyntaxKind(23);
pub const L_ANGLE: SyntaxKind = SyntaxKind(24);
pub const R_ANGLE: SyntaxKind = SyntaxKind(25);
pub const AT: SyntaxKind = SyntaxKind(26);
pub const POUND: SyntaxKind = SyntaxKind(27);
pub const TILDE: SyntaxKind = SyntaxKind(28);
pub const QUESTION: SyntaxKind = SyntaxKind(29);
pub const COLON: SyntaxKind = SyntaxKind(30);
pub const COLONCOLON: SyntaxKind = SyntaxKind(31);
pub const DOLLAR: SyntaxKind = SyntaxKind(32);
pub const EQ: SyntaxKind = SyntaxKind(33);
pub const EQEQ: SyntaxKind = SyntaxKind(34);
pub const FAT_ARROW: SyntaxKind = SyntaxKind(35);
pub const NEQ: SyntaxKind = SyntaxKind(36);
pub const EXCL: SyntaxKind = SyntaxKind(37);
pub const LIFETIME: SyntaxKind = SyntaxKind(38);
pub const CHAR: SyntaxKind = SyntaxKind(39);
pub const BYTE: SyntaxKind = SyntaxKind(40);
pub const STRING: SyntaxKind = SyntaxKind(41);
pub const RAW_STRING: SyntaxKind = SyntaxKind(42);
pub const BYTE_STRING: SyntaxKind = SyntaxKind(43);
pub const RAW_BYTE_STRING: SyntaxKind = SyntaxKind(44);
pub const PLUS: SyntaxKind = SyntaxKind(45);
pub const MINUS: SyntaxKind = SyntaxKind(46);
pub const STAR: SyntaxKind = SyntaxKind(47);
pub const SLASH: SyntaxKind = SyntaxKind(48);
pub const CARET: SyntaxKind = SyntaxKind(49);
pub const PERCENT: SyntaxKind = SyntaxKind(50);
pub const AMPERSAND: SyntaxKind = SyntaxKind(51);
pub const PIPE: SyntaxKind = SyntaxKind(52);
pub const THIN_ARROW: SyntaxKind = SyntaxKind(53);
pub const COMMENT: SyntaxKind = SyntaxKind(54);
pub const DOC_COMMENT: SyntaxKind = SyntaxKind(55);
pub const SHEBANG: SyntaxKind = SyntaxKind(56);
pub const FILE: SyntaxKind = SyntaxKind(57);
pub const STRUCT_ITEM: SyntaxKind = SyntaxKind(58);
pub const STRUCT_FIELD: SyntaxKind = SyntaxKind(59);
pub const FN_ITEM: SyntaxKind = SyntaxKind(60);
pub const ATTR: SyntaxKind = SyntaxKind(61);
pub const META_ITEM: SyntaxKind = SyntaxKind(62);
pub const TRUE_KW: SyntaxKind = SyntaxKind(6);
pub const FALSE_KW: SyntaxKind = SyntaxKind(7);
pub const ERROR: SyntaxKind = SyntaxKind(8);
pub const IDENT: SyntaxKind = SyntaxKind(9);
pub const UNDERSCORE: SyntaxKind = SyntaxKind(10);
pub const WHITESPACE: SyntaxKind = SyntaxKind(11);
pub const INT_NUMBER: SyntaxKind = SyntaxKind(12);
pub const FLOAT_NUMBER: SyntaxKind = SyntaxKind(13);
pub const SEMI: SyntaxKind = SyntaxKind(14);
pub const COMMA: SyntaxKind = SyntaxKind(15);
pub const DOT: SyntaxKind = SyntaxKind(16);
pub const DOTDOT: SyntaxKind = SyntaxKind(17);
pub const DOTDOTDOT: SyntaxKind = SyntaxKind(18);
pub const DOTDOTEQ: SyntaxKind = SyntaxKind(19);
pub const L_PAREN: SyntaxKind = SyntaxKind(20);
pub const R_PAREN: SyntaxKind = SyntaxKind(21);
pub const L_CURLY: SyntaxKind = SyntaxKind(22);
pub const R_CURLY: SyntaxKind = SyntaxKind(23);
pub const L_BRACK: SyntaxKind = SyntaxKind(24);
pub const R_BRACK: SyntaxKind = SyntaxKind(25);
pub const L_ANGLE: SyntaxKind = SyntaxKind(26);
pub const R_ANGLE: SyntaxKind = SyntaxKind(27);
pub const AT: SyntaxKind = SyntaxKind(28);
pub const POUND: SyntaxKind = SyntaxKind(29);
pub const TILDE: SyntaxKind = SyntaxKind(30);
pub const QUESTION: SyntaxKind = SyntaxKind(31);
pub const COLON: SyntaxKind = SyntaxKind(32);
pub const COLONCOLON: SyntaxKind = SyntaxKind(33);
pub const DOLLAR: SyntaxKind = SyntaxKind(34);
pub const EQ: SyntaxKind = SyntaxKind(35);
pub const EQEQ: SyntaxKind = SyntaxKind(36);
pub const FAT_ARROW: SyntaxKind = SyntaxKind(37);
pub const NEQ: SyntaxKind = SyntaxKind(38);
pub const EXCL: SyntaxKind = SyntaxKind(39);
pub const LIFETIME: SyntaxKind = SyntaxKind(40);
pub const CHAR: SyntaxKind = SyntaxKind(41);
pub const BYTE: SyntaxKind = SyntaxKind(42);
pub const STRING: SyntaxKind = SyntaxKind(43);
pub const RAW_STRING: SyntaxKind = SyntaxKind(44);
pub const BYTE_STRING: SyntaxKind = SyntaxKind(45);
pub const RAW_BYTE_STRING: SyntaxKind = SyntaxKind(46);
pub const PLUS: SyntaxKind = SyntaxKind(47);
pub const MINUS: SyntaxKind = SyntaxKind(48);
pub const STAR: SyntaxKind = SyntaxKind(49);
pub const SLASH: SyntaxKind = SyntaxKind(50);
pub const CARET: SyntaxKind = SyntaxKind(51);
pub const PERCENT: SyntaxKind = SyntaxKind(52);
pub const AMPERSAND: SyntaxKind = SyntaxKind(53);
pub const PIPE: SyntaxKind = SyntaxKind(54);
pub const THIN_ARROW: SyntaxKind = SyntaxKind(55);
pub const COMMENT: SyntaxKind = SyntaxKind(56);
pub const DOC_COMMENT: SyntaxKind = SyntaxKind(57);
pub const SHEBANG: SyntaxKind = SyntaxKind(58);
pub const FILE: SyntaxKind = SyntaxKind(59);
pub const STRUCT_ITEM: SyntaxKind = SyntaxKind(60);
pub const STRUCT_FIELD: SyntaxKind = SyntaxKind(61);
pub const FN_ITEM: SyntaxKind = SyntaxKind(62);
pub const ATTR: SyntaxKind = SyntaxKind(63);
pub const META_ITEM: SyntaxKind = SyntaxKind(64);
static INFOS: [SyntaxInfo; 63] = [
static INFOS: [SyntaxInfo; 65] = [
SyntaxInfo { name: "USE_KW" },
SyntaxInfo { name: "FN_KW" },
SyntaxInfo { name: "STRUCT_KW" },
SyntaxInfo { name: "ENUM_KW" },
SyntaxInfo { name: "TRAIT_KW" },
SyntaxInfo { name: "IMPL_KW" },
SyntaxInfo { name: "TRUE_KW" },
SyntaxInfo { name: "FALSE_KW" },
SyntaxInfo { name: "ERROR" },
SyntaxInfo { name: "IDENT" },
SyntaxInfo { name: "UNDERSCORE" },
@ -143,6 +147,8 @@ pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {
"enum" => Some(ENUM_KW),
"trait" => Some(TRAIT_KW),
"impl" => Some(IMPL_KW),
"true" => Some(TRUE_KW),
"false" => Some(FALSE_KW),
_ => None,
}
}

View file

@ -1 +1 @@
fn use struct trait enum impl
fn use struct trait enum impl true false

View file

@ -9,4 +9,8 @@ WHITESPACE 1 " "
ENUM_KW 4 "enum"
WHITESPACE 1 " "
IMPL_KW 4 "impl"
WHITESPACE 1 " "
TRUE_KW 4 "true"
WHITESPACE 1 " "
FALSE_KW 5 "false"
WHITESPACE 1 "\n"

View file

@ -7,52 +7,44 @@ FILE@[0; 236)
IDENT@[3; 7)
R_BRACK@[7; 8)
WHITESPACE@[8; 9)
ATTR@[9; 24)
ATTR@[9; 17)
POUND@[9; 10)
EXCL@[10; 11)
L_BRACK@[11; 12)
META_ITEM@[12; 22)
META_ITEM@[12; 17)
IDENT@[12; 16)
L_PAREN@[16; 17)
META_ITEM@[17; 21)
IDENT@[17; 21)
R_PAREN@[21; 22)
err: `expected R_PAREN`
err: `expected R_BRACK`
ERROR@[17; 236)
err: `expected item`
TRUE_KW@[17; 21)
R_PAREN@[21; 22)
R_BRACK@[22; 23)
WHITESPACE@[23; 24)
ATTR@[24; 40)
POUND@[24; 25)
EXCL@[25; 26)
L_BRACK@[26; 27)
META_ITEM@[27; 38)
IDENT@[27; 31)
L_PAREN@[31; 32)
META_ITEM@[32; 37)
IDENT@[32; 37)
R_PAREN@[37; 38)
IDENT@[27; 31)
L_PAREN@[31; 32)
IDENT@[32; 37)
R_PAREN@[37; 38)
R_BRACK@[38; 39)
WHITESPACE@[39; 40)
ATTR@[40; 66)
POUND@[40; 41)
EXCL@[41; 42)
L_BRACK@[42; 43)
META_ITEM@[43; 66)
IDENT@[43; 47)
L_PAREN@[47; 48)
META_ITEM@[48; 53)
IDENT@[48; 53)
COMMA@[53; 54)
WHITESPACE@[54; 55)
INT_NUMBER@[55; 58)
COMMA@[58; 59)
META_ITEM@[59; 64)
WHITESPACE@[59; 60)
IDENT@[60; 64)
COMMA@[64; 65)
err: `expected R_PAREN`
WHITESPACE@[65; 66)
err: `expected R_BRACK`
ERROR@[66; 236)
err: `expected item`
IDENT@[43; 47)
L_PAREN@[47; 48)
IDENT@[48; 53)
COMMA@[53; 54)
WHITESPACE@[54; 55)
INT_NUMBER@[55; 58)
COMMA@[58; 59)
WHITESPACE@[59; 60)
TRUE_KW@[60; 64)
COMMA@[64; 65)
WHITESPACE@[65; 66)
STRING@[66; 72)
COMMA@[72; 73)
WHITESPACE@[73; 74)
@ -95,7 +87,7 @@ FILE@[0; 236)
WHITESPACE@[146; 147)
EQ@[147; 148)
WHITESPACE@[148; 149)
IDENT@[149; 153)
TRUE_KW@[149; 153)
R_PAREN@[153; 154)
R_BRACK@[154; 155)
WHITESPACE@[155; 156)
@ -104,7 +96,7 @@ FILE@[0; 236)
L_BRACK@[158; 159)
IDENT@[159; 166)
L_PAREN@[166; 167)
IDENT@[167; 171)
TRUE_KW@[167; 171)
R_PAREN@[171; 172)
R_BRACK@[172; 173)
WHITESPACE@[173; 174)