From 75761c0e47d8c20a490a3d61ea64d2413d3c3570 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 22 Jul 2019 17:47:33 +0300 Subject: add rustc_lexer --- crates/ra_syntax/tests/data/lexer/0004_numbers.txt | 12 ++-- .../tests/data/lexer/0014_unclosed_char.txt | 2 +- .../data/parser/err/0002_duplicate_shebang.txt | 38 +++++++++++- .../tests/data/parser/err/0030_string_suffixes.rs | 6 -- .../tests/data/parser/err/0030_string_suffixes.txt | 70 ---------------------- .../tests/data/parser/ok/0030_string_suffixes.rs | 6 ++ .../tests/data/parser/ok/0030_string_suffixes.txt | 63 +++++++++++++++++++ 7 files changed, 110 insertions(+), 87 deletions(-) delete mode 100644 crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.rs delete mode 100644 crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt create mode 100644 crates/ra_syntax/tests/data/parser/ok/0030_string_suffixes.rs create mode 100644 crates/ra_syntax/tests/data/parser/ok/0030_string_suffixes.txt (limited to 'crates/ra_syntax/tests') diff --git a/crates/ra_syntax/tests/data/lexer/0004_numbers.txt b/crates/ra_syntax/tests/data/lexer/0004_numbers.txt index 39988aedc..7bb89b8ae 100644 --- a/crates/ra_syntax/tests/data/lexer/0004_numbers.txt +++ b/crates/ra_syntax/tests/data/lexer/0004_numbers.txt @@ -12,9 +12,9 @@ INT_NUMBER 2 "0_" WHITESPACE 1 " " FLOAT_NUMBER 2 "0." WHITESPACE 1 " " -INT_NUMBER 2 "0e" +FLOAT_NUMBER 2 "0e" WHITESPACE 1 " " -INT_NUMBER 2 "0E" +FLOAT_NUMBER 2 "0E" WHITESPACE 1 " " INT_NUMBER 2 "0z" WHITESPACE 1 "\n" @@ -32,9 +32,9 @@ INT_NUMBER 6 "0_1279" WHITESPACE 1 " " FLOAT_NUMBER 6 "0.1279" WHITESPACE 1 " " -INT_NUMBER 6 "0e1279" +FLOAT_NUMBER 6 "0e1279" WHITESPACE 1 " " -INT_NUMBER 6 "0E1279" +FLOAT_NUMBER 6 "0E1279" WHITESPACE 1 "\n" INT_NUMBER 1 "0" DOT 1 "." @@ -47,9 +47,7 @@ IDENT 3 "foo" L_PAREN 1 "(" R_PAREN 1 ")" WHITESPACE 1 "\n" -INT_NUMBER 2 "0e" -PLUS 1 "+" -INT_NUMBER 1 "1" +FLOAT_NUMBER 4 "0e+1" WHITESPACE 1 "\n" INT_NUMBER 1 "0" DOT 1 "." diff --git a/crates/ra_syntax/tests/data/lexer/0014_unclosed_char.txt b/crates/ra_syntax/tests/data/lexer/0014_unclosed_char.txt index 812dfbc18..737a300ee 100644 --- a/crates/ra_syntax/tests/data/lexer/0014_unclosed_char.txt +++ b/crates/ra_syntax/tests/data/lexer/0014_unclosed_char.txt @@ -1 +1 @@ -CHAR 2 "\'1" +LIFETIME 2 "\'1" diff --git a/crates/ra_syntax/tests/data/parser/err/0002_duplicate_shebang.txt b/crates/ra_syntax/tests/data/parser/err/0002_duplicate_shebang.txt index 76d186a3c..84867026f 100644 --- a/crates/ra_syntax/tests/data/parser/err/0002_duplicate_shebang.txt +++ b/crates/ra_syntax/tests/data/parser/err/0002_duplicate_shebang.txt @@ -1,7 +1,39 @@ SOURCE_FILE@[0; 42) SHEBANG@[0; 20) "#!/use/bin/env rusti" WHITESPACE@[20; 21) "\n" - ERROR@[21; 41) - SHEBANG@[21; 41) "#!/use/bin/env rusti" + ATTR@[21; 23) + POUND@[21; 22) "#" + EXCL@[22; 23) "!" + ERROR@[23; 24) + SLASH@[23; 24) "/" + USE_ITEM@[24; 28) + USE_KW@[24; 27) "use" + ERROR@[27; 28) + SLASH@[27; 28) "/" + MACRO_CALL@[28; 31) + PATH@[28; 31) + PATH_SEGMENT@[28; 31) + NAME_REF@[28; 31) + IDENT@[28; 31) "bin" + ERROR@[31; 32) + SLASH@[31; 32) "/" + MACRO_CALL@[32; 41) + PATH@[32; 35) + PATH_SEGMENT@[32; 35) + NAME_REF@[32; 35) + IDENT@[32; 35) "env" + WHITESPACE@[35; 36) " " + NAME@[36; 41) + IDENT@[36; 41) "rusti" WHITESPACE@[41; 42) "\n" -error 21: expected an item +error 23: expected `[` +error 23: expected an item +error 27: expected one of `*`, `::`, `{`, `self`, `super` or an indentifier +error 28: expected SEMI +error 31: expected EXCL +error 31: expected `{`, `[`, `(` +error 31: expected SEMI +error 31: expected an item +error 35: expected EXCL +error 41: expected `{`, `[`, `(` +error 41: expected SEMI diff --git a/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.rs b/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.rs deleted file mode 100644 index 261aad1fb..000000000 --- a/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - let _ = 'c'u32; - let _ = "string"invalid; - let _ = b'b'_suff; - let _ = b"bs"invalid; -} diff --git a/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt b/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt deleted file mode 100644 index b0acfa5d2..000000000 --- a/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt +++ /dev/null @@ -1,70 +0,0 @@ -SOURCE_FILE@[0; 112) - FN_DEF@[0; 111) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 7) - IDENT@[3; 7) "main" - PARAM_LIST@[7; 9) - L_PAREN@[7; 8) "(" - R_PAREN@[8; 9) ")" - WHITESPACE@[9; 10) " " - BLOCK@[10; 111) - L_CURLY@[10; 11) "{" - WHITESPACE@[11; 16) "\n " - LET_STMT@[16; 27) - LET_KW@[16; 19) "let" - WHITESPACE@[19; 20) " " - PLACEHOLDER_PAT@[20; 21) - UNDERSCORE@[20; 21) "_" - WHITESPACE@[21; 22) " " - EQ@[22; 23) "=" - WHITESPACE@[23; 24) " " - LITERAL@[24; 27) - CHAR@[24; 27) "\'c\'" - EXPR_STMT@[27; 31) - PATH_EXPR@[27; 30) - PATH@[27; 30) - PATH_SEGMENT@[27; 30) - NAME_REF@[27; 30) - IDENT@[27; 30) "u32" - SEMI@[30; 31) ";" - WHITESPACE@[31; 36) "\n " - LET_STMT@[36; 60) - LET_KW@[36; 39) "let" - WHITESPACE@[39; 40) " " - PLACEHOLDER_PAT@[40; 41) - UNDERSCORE@[40; 41) "_" - WHITESPACE@[41; 42) " " - EQ@[42; 43) "=" - WHITESPACE@[43; 44) " " - LITERAL@[44; 59) - STRING@[44; 59) "\"string\"invalid" - SEMI@[59; 60) ";" - WHITESPACE@[60; 65) "\n " - LET_STMT@[65; 83) - LET_KW@[65; 68) "let" - WHITESPACE@[68; 69) " " - PLACEHOLDER_PAT@[69; 70) - UNDERSCORE@[69; 70) "_" - WHITESPACE@[70; 71) " " - EQ@[71; 72) "=" - WHITESPACE@[72; 73) " " - LITERAL@[73; 82) - BYTE@[73; 82) "b\'b\'_suff" - SEMI@[82; 83) ";" - WHITESPACE@[83; 88) "\n " - LET_STMT@[88; 109) - LET_KW@[88; 91) "let" - WHITESPACE@[91; 92) " " - PLACEHOLDER_PAT@[92; 93) - UNDERSCORE@[92; 93) "_" - WHITESPACE@[93; 94) " " - EQ@[94; 95) "=" - WHITESPACE@[95; 96) " " - LITERAL@[96; 108) - BYTE_STRING@[96; 108) "b\"bs\"invalid" - SEMI@[108; 109) ";" - WHITESPACE@[109; 110) "\n" - R_CURLY@[110; 111) "}" - WHITESPACE@[111; 112) "\n" -error 27: expected SEMI diff --git a/crates/ra_syntax/tests/data/parser/ok/0030_string_suffixes.rs b/crates/ra_syntax/tests/data/parser/ok/0030_string_suffixes.rs new file mode 100644 index 000000000..261aad1fb --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0030_string_suffixes.rs @@ -0,0 +1,6 @@ +fn main() { + let _ = 'c'u32; + let _ = "string"invalid; + let _ = b'b'_suff; + let _ = b"bs"invalid; +} diff --git a/crates/ra_syntax/tests/data/parser/ok/0030_string_suffixes.txt b/crates/ra_syntax/tests/data/parser/ok/0030_string_suffixes.txt new file mode 100644 index 000000000..4f7e809c5 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0030_string_suffixes.txt @@ -0,0 +1,63 @@ +SOURCE_FILE@[0; 112) + FN_DEF@[0; 111) + FN_KW@[0; 2) "fn" + WHITESPACE@[2; 3) " " + NAME@[3; 7) + IDENT@[3; 7) "main" + PARAM_LIST@[7; 9) + L_PAREN@[7; 8) "(" + R_PAREN@[8; 9) ")" + WHITESPACE@[9; 10) " " + BLOCK@[10; 111) + L_CURLY@[10; 11) "{" + WHITESPACE@[11; 16) "\n " + LET_STMT@[16; 31) + LET_KW@[16; 19) "let" + WHITESPACE@[19; 20) " " + PLACEHOLDER_PAT@[20; 21) + UNDERSCORE@[20; 21) "_" + WHITESPACE@[21; 22) " " + EQ@[22; 23) "=" + WHITESPACE@[23; 24) " " + LITERAL@[24; 30) + CHAR@[24; 30) "\'c\'u32" + SEMI@[30; 31) ";" + WHITESPACE@[31; 36) "\n " + LET_STMT@[36; 60) + LET_KW@[36; 39) "let" + WHITESPACE@[39; 40) " " + PLACEHOLDER_PAT@[40; 41) + UNDERSCORE@[40; 41) "_" + WHITESPACE@[41; 42) " " + EQ@[42; 43) "=" + WHITESPACE@[43; 44) " " + LITERAL@[44; 59) + STRING@[44; 59) "\"string\"invalid" + SEMI@[59; 60) ";" + WHITESPACE@[60; 65) "\n " + LET_STMT@[65; 83) + LET_KW@[65; 68) "let" + WHITESPACE@[68; 69) " " + PLACEHOLDER_PAT@[69; 70) + UNDERSCORE@[69; 70) "_" + WHITESPACE@[70; 71) " " + EQ@[71; 72) "=" + WHITESPACE@[72; 73) " " + LITERAL@[73; 82) + BYTE@[73; 82) "b\'b\'_suff" + SEMI@[82; 83) ";" + WHITESPACE@[83; 88) "\n " + LET_STMT@[88; 109) + LET_KW@[88; 91) "let" + WHITESPACE@[91; 92) " " + PLACEHOLDER_PAT@[92; 93) + UNDERSCORE@[92; 93) "_" + WHITESPACE@[93; 94) " " + EQ@[94; 95) "=" + WHITESPACE@[95; 96) " " + LITERAL@[96; 108) + BYTE_STRING@[96; 108) "b\"bs\"invalid" + SEMI@[108; 109) ";" + WHITESPACE@[109; 110) "\n" + R_CURLY@[110; 111) "}" + WHITESPACE@[111; 112) "\n" -- cgit v1.2.3