From 376639c70f94f1f26c7fbd86a9b5adebfa400f44 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 20:52:56 +0300 Subject: Parse crate paths in expressions --- crates/ra_syntax/src/grammar/expressions/atom.rs | 2 +- .../data/parser/ok/0035_crate_path_in_call.rs | 3 ++ .../data/parser/ok/0035_crate_path_in_call.txt | 41 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs create mode 100644 crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs index a720d255f..e21de68c5 100644 --- a/crates/ra_syntax/src/grammar/expressions/atom.rs +++ b/crates/ra_syntax/src/grammar/expressions/atom.rs @@ -30,7 +30,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = token_set_union![ LITERAL_FIRST, token_set![L_CURLY, L_PAREN, L_BRACK, PIPE, MOVE_KW, IF_KW, WHILE_KW, MATCH_KW, UNSAFE_KW, - RETURN_KW, IDENT, SELF_KW, SUPER_KW, COLONCOLON, BREAK_KW, CONTINUE_KW, LIFETIME ], + RETURN_KW, IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLONCOLON, BREAK_KW, CONTINUE_KW, LIFETIME ], ]; const EXPR_RECOVERY_SET: TokenSet = diff --git a/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs new file mode 100644 index 000000000..f1ed30220 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs @@ -0,0 +1,3 @@ +fn main() { + make_query(crate::module_map::module_tree); +} diff --git a/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt new file mode 100644 index 000000000..364315180 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt @@ -0,0 +1,41 @@ +ROOT@[0; 62) + FN_DEF@[0; 61) + FN_KW@[0; 2) + 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; 61) + L_CURLY@[10; 11) + WHITESPACE@[11; 16) + EXPR_STMT@[16; 59) + CALL_EXPR@[16; 58) + PATH_EXPR@[16; 26) + PATH@[16; 26) + PATH_SEGMENT@[16; 26) + NAME_REF@[16; 26) + IDENT@[16; 26) "make_query" + ARG_LIST@[26; 58) + L_PAREN@[26; 27) + PATH_EXPR@[27; 57) + PATH@[27; 57) + PATH@[27; 44) + PATH@[27; 32) + PATH_SEGMENT@[27; 32) + CRATE_KW@[27; 32) + COLONCOLON@[32; 34) + PATH_SEGMENT@[34; 44) + NAME_REF@[34; 44) + IDENT@[34; 44) "module_map" + COLONCOLON@[44; 46) + PATH_SEGMENT@[46; 57) + NAME_REF@[46; 57) + IDENT@[46; 57) "module_tree" + R_PAREN@[57; 58) + SEMI@[58; 59) + WHITESPACE@[59; 60) + R_CURLY@[60; 61) + WHITESPACE@[61; 62) -- cgit v1.2.3