From de02d2891ec7f7b295e33887d49de954f677387a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 Aug 2018 11:46:46 +0300 Subject: [PATCH] full range expr --- .../libsyntax2/src/grammar/expressions/mod.rs | 6 +++- .../parser/inline/0102_full_range_expr.rs | 1 + .../parser/inline/0102_full_range_expr.txt | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 crates/libsyntax2/tests/data/parser/inline/0102_full_range_expr.rs create mode 100644 crates/libsyntax2/tests/data/parser/inline/0102_full_range_expr.txt diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs index e56f3d30e2..feef5f1d67 100644 --- a/crates/libsyntax2/src/grammar/expressions/mod.rs +++ b/crates/libsyntax2/src/grammar/expressions/mod.rs @@ -174,10 +174,14 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option { p.bump(); PREFIX_EXPR } + // test full_range_expr + // fn foo() { xs[..]; } DOTDOT => { m = p.start(); p.bump(); - expr_bp(p, r, 2); + if EXPR_FIRST.contains(p.current()) { + expr_bp(p, r, 2); + } return Some(m.complete(p, RANGE_EXPR)); } _ => { diff --git a/crates/libsyntax2/tests/data/parser/inline/0102_full_range_expr.rs b/crates/libsyntax2/tests/data/parser/inline/0102_full_range_expr.rs new file mode 100644 index 0000000000..ae21ad94cb --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/inline/0102_full_range_expr.rs @@ -0,0 +1 @@ +fn foo() { xs[..]; } diff --git a/crates/libsyntax2/tests/data/parser/inline/0102_full_range_expr.txt b/crates/libsyntax2/tests/data/parser/inline/0102_full_range_expr.txt new file mode 100644 index 0000000000..8e7b403c5c --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/inline/0102_full_range_expr.txt @@ -0,0 +1,28 @@ +FILE@[0; 21) + FN_DEF@[0; 20) + FN_KW@[0; 2) + WHITESPACE@[2; 3) + NAME@[3; 6) + IDENT@[3; 6) "foo" + PARAM_LIST@[6; 8) + L_PAREN@[6; 7) + R_PAREN@[7; 8) + WHITESPACE@[8; 9) + BLOCK_EXPR@[9; 20) + L_CURLY@[9; 10) + WHITESPACE@[10; 11) + EXPR_STMT@[11; 18) + INDEX_EXPR@[11; 17) + PATH_EXPR@[11; 13) + PATH@[11; 13) + PATH_SEGMENT@[11; 13) + NAME_REF@[11; 13) + IDENT@[11; 13) "xs" + L_BRACK@[13; 14) + RANGE_EXPR@[14; 16) + DOTDOT@[14; 16) + R_BRACK@[16; 17) + SEMI@[17; 18) + WHITESPACE@[18; 19) + R_CURLY@[19; 20) + WHITESPACE@[20; 21)