From d44169ab1e2897a90f8aa7d7672d2fe318cceb27 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 5 Aug 2018 18:18:02 +0300 Subject: ampersand -> amp --- src/grammar.ron | 4 +- src/grammar/expressions/mod.rs | 8 +- src/grammar/params.rs | 8 +- src/grammar/patterns.rs | 4 +- src/grammar/types.rs | 4 +- src/syntax_kinds/generated.rs | 14 ++-- tests/data/lexer/0005_symbols.txt | 2 +- tests/data/parser/inline/0026_reference_type;.txt | 6 +- tests/data/parser/inline/0035_ref_pat.txt | 4 +- tests/data/parser/inline/0044_ref_expr.txt | 6 +- tests/data/parser/inline/0054_impl_item_items.txt | 2 +- tests/data/parser/inline/0055_self_param.txt | 6 +- tests/data/parser/inline/0062_deref_expr.txt | 2 +- tests/data/parser/inline/0084_compound_ops.rs | 6 ++ tests/data/parser/inline/0084_compound_ops.txt | 89 +++++++++++++++++++++++ tests/data/parser/inline/0084_loop_expr.rs | 3 + tests/data/parser/inline/0084_loop_expr.txt | 24 ++++++ 17 files changed, 157 insertions(+), 35 deletions(-) create mode 100644 tests/data/parser/inline/0084_compound_ops.rs create mode 100644 tests/data/parser/inline/0084_compound_ops.txt create mode 100644 tests/data/parser/inline/0084_loop_expr.rs create mode 100644 tests/data/parser/inline/0084_loop_expr.txt diff --git a/src/grammar.ron b/src/grammar.ron index d5bdb206c..df769bba6 100644 --- a/src/grammar.ron +++ b/src/grammar.ron @@ -15,7 +15,7 @@ Grammar( ["~", "TILDE"], ["?", "QUESTION"], ["$", "DOLLAR"], - ["&", "AMPERSAND"], + ["&", "AMP"], ["|", "PIPE"], ["+", "PLUS"], ["*", "STAR"], @@ -41,7 +41,7 @@ Grammar( [">=", "GTEQ"], ["+=", "PLUSEQ"], ["-=", "MINUSEQ"], - ["&&", "AMPERSANDAMPERSAND"], + ["&&", "AMPAMP"], ["||", "PIPEPIPE"], ], keywords: [ diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs index 18e3f5798..e0b4ced74 100644 --- a/src/grammar/expressions/mod.rs +++ b/src/grammar/expressions/mod.rs @@ -68,8 +68,8 @@ fn current_op(p: &Parser) -> (u8, Op) { if p.at_compound2(PIPE, PIPE) { return (3, Op::Composite(PIPEPIPE, 2)); } - if p.at_compound2(AMPERSAND, AMPERSAND) { - return (4, Op::Composite(AMPERSANDAMPERSAND, 2)); + if p.at_compound2(AMP, AMP) { + return (4, Op::Composite(AMPAMP, 2)); } if p.at_compound2(L_ANGLE, EQ) { return (5, Op::Composite(LTEQ, 2)); @@ -113,7 +113,7 @@ fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) { const UNARY_EXPR_FIRST: TokenSet = token_set_union![ - token_set![AMPERSAND, STAR, EXCL], + token_set![AMP, STAR, EXCL], atom::ATOM_EXPR_FIRST, ]; @@ -125,7 +125,7 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option { // let _ = &1; // let _ = &mut &f(); // } - AMPERSAND => { + AMP => { m = p.start(); p.bump(); p.eat(MUT_KW); diff --git a/src/grammar/params.rs b/src/grammar/params.rs index be985c80f..034542df1 100644 --- a/src/grammar/params.rs +++ b/src/grammar/params.rs @@ -53,10 +53,10 @@ fn self_param(p: &mut Parser) { let la3 = p.nth(3); let n_toks = match (p.current(), la1, la2, la3) { (SELF_KW, _, _, _) => 1, - (AMPERSAND, SELF_KW, _, _) => 2, - (AMPERSAND, MUT_KW, SELF_KW, _) => 3, - (AMPERSAND, LIFETIME, SELF_KW, _) => 3, - (AMPERSAND, LIFETIME, MUT_KW, SELF_KW) => 4, + (AMP, SELF_KW, _, _) => 2, + (AMP, MUT_KW, SELF_KW, _) => 3, + (AMP, LIFETIME, SELF_KW, _) => 3, + (AMP, LIFETIME, MUT_KW, SELF_KW) => 4, _ => return, }; let m = p.start(); diff --git a/src/grammar/patterns.rs b/src/grammar/patterns.rs index 770274686..d67f180fa 100644 --- a/src/grammar/patterns.rs +++ b/src/grammar/patterns.rs @@ -15,7 +15,7 @@ pub(super) fn pattern(p: &mut Parser) { match la0 { UNDERSCORE => placeholder_pat(p), - AMPERSAND => ref_pat(p), + AMP => ref_pat(p), _ => p.err_and_bump("expected pattern"), } } @@ -108,7 +108,7 @@ fn placeholder_pat(p: &mut Parser) { // let &mut b = (); // } fn ref_pat(p: &mut Parser) { - assert!(p.at(AMPERSAND)); + assert!(p.at(AMP)); let m = p.start(); p.bump(); p.eat(MUT_KW); diff --git a/src/grammar/types.rs b/src/grammar/types.rs index 565037cb0..9e63c9b2a 100644 --- a/src/grammar/types.rs +++ b/src/grammar/types.rs @@ -6,7 +6,7 @@ pub(super) fn type_(p: &mut Parser) { EXCL => never_type(p), STAR => pointer_type(p), L_BRACK => array_or_slice_type(p), - AMPERSAND => reference_type(p), + AMP => reference_type(p), UNDERSCORE => placeholder_type(p), FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), FOR_KW => for_type(p), @@ -130,7 +130,7 @@ fn array_or_slice_type(p: &mut Parser) { // type B = &'static (); // type C = &mut (); fn reference_type(p: &mut Parser) { - assert!(p.at(AMPERSAND)); + assert!(p.at(AMP)); let m = p.start(); p.bump(); p.eat(LIFETIME); diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs index 20f01c505..1bce34443 100644 --- a/src/syntax_kinds/generated.rs +++ b/src/syntax_kinds/generated.rs @@ -20,7 +20,7 @@ pub enum SyntaxKind { TILDE, QUESTION, DOLLAR, - AMPERSAND, + AMP, PIPE, PLUS, STAR, @@ -44,7 +44,7 @@ pub enum SyntaxKind { GTEQ, PLUSEQ, MINUSEQ, - AMPERSANDAMPERSAND, + AMPAMP, PIPEPIPE, USE_KW, FN_KW, @@ -251,7 +251,7 @@ impl SyntaxKind { TILDE => &SyntaxInfo { name: "TILDE" }, QUESTION => &SyntaxInfo { name: "QUESTION" }, DOLLAR => &SyntaxInfo { name: "DOLLAR" }, - AMPERSAND => &SyntaxInfo { name: "AMPERSAND" }, + AMP => &SyntaxInfo { name: "AMP" }, PIPE => &SyntaxInfo { name: "PIPE" }, PLUS => &SyntaxInfo { name: "PLUS" }, STAR => &SyntaxInfo { name: "STAR" }, @@ -275,7 +275,7 @@ impl SyntaxKind { GTEQ => &SyntaxInfo { name: "GTEQ" }, PLUSEQ => &SyntaxInfo { name: "PLUSEQ" }, MINUSEQ => &SyntaxInfo { name: "MINUSEQ" }, - AMPERSANDAMPERSAND => &SyntaxInfo { name: "AMPERSANDAMPERSAND" }, + AMPAMP => &SyntaxInfo { name: "AMPAMP" }, PIPEPIPE => &SyntaxInfo { name: "PIPEPIPE" }, USE_KW => &SyntaxInfo { name: "USE_KW" }, FN_KW => &SyntaxInfo { name: "FN_KW" }, @@ -473,7 +473,7 @@ impl SyntaxKind { '~' => TILDE, '?' => QUESTION, '$' => DOLLAR, - '&' => AMPERSAND, + '&' => AMP, '|' => PIPE, '+' => PLUS, '*' => STAR, @@ -502,7 +502,7 @@ impl SyntaxKind { TILDE => "~", QUESTION => "?", DOLLAR => "$", - AMPERSAND => "&", + AMP => "&", PIPE => "|", PLUS => "+", STAR => "*", @@ -526,7 +526,7 @@ impl SyntaxKind { GTEQ => ">=", PLUSEQ => "+=", MINUSEQ => "-=", - AMPERSANDAMPERSAND => "&&", + AMPAMP => "&&", PIPEPIPE => "||", USE_KW => "use", diff --git a/tests/data/lexer/0005_symbols.txt b/tests/data/lexer/0005_symbols.txt index 0f99c24cd..a6bc83a6f 100644 --- a/tests/data/lexer/0005_symbols.txt +++ b/tests/data/lexer/0005_symbols.txt @@ -28,7 +28,7 @@ QUESTION 1 "?" WHITESPACE 1 " " DOLLAR 1 "$" WHITESPACE 1 " " -AMPERSAND 1 "&" +AMP 1 "&" WHITESPACE 1 " " PIPE 1 "|" WHITESPACE 1 " " diff --git a/tests/data/parser/inline/0026_reference_type;.txt b/tests/data/parser/inline/0026_reference_type;.txt index 665c021e1..10fc5f636 100644 --- a/tests/data/parser/inline/0026_reference_type;.txt +++ b/tests/data/parser/inline/0026_reference_type;.txt @@ -8,7 +8,7 @@ FILE@[0; 54) EQ@[7; 8) REFERENCE_TYPE@[8; 12) WHITESPACE@[8; 9) - AMPERSAND@[9; 10) + AMP@[9; 10) TUPLE_TYPE@[10; 12) L_PAREN@[10; 11) R_PAREN@[11; 12) @@ -23,7 +23,7 @@ FILE@[0; 54) EQ@[21; 22) REFERENCE_TYPE@[22; 34) WHITESPACE@[22; 23) - AMPERSAND@[23; 24) + AMP@[23; 24) LIFETIME@[24; 31) "'static" TUPLE_TYPE@[31; 34) WHITESPACE@[31; 32) @@ -40,7 +40,7 @@ FILE@[0; 54) EQ@[43; 44) REFERENCE_TYPE@[44; 52) WHITESPACE@[44; 45) - AMPERSAND@[45; 46) + AMP@[45; 46) MUT_KW@[46; 49) TUPLE_TYPE@[49; 52) WHITESPACE@[49; 50) diff --git a/tests/data/parser/inline/0035_ref_pat.txt b/tests/data/parser/inline/0035_ref_pat.txt index 27a31d2ab..b3aa6d285 100644 --- a/tests/data/parser/inline/0035_ref_pat.txt +++ b/tests/data/parser/inline/0035_ref_pat.txt @@ -15,7 +15,7 @@ FILE@[0; 52) LET_KW@[16; 19) REF_PAT@[19; 23) WHITESPACE@[19; 20) - AMPERSAND@[20; 21) + AMP@[20; 21) BIND_PAT@[21; 23) NAME@[21; 23) IDENT@[21; 22) "a" @@ -31,7 +31,7 @@ FILE@[0; 52) LET_KW@[33; 36) REF_PAT@[36; 44) WHITESPACE@[36; 37) - AMPERSAND@[37; 38) + AMP@[37; 38) MUT_KW@[38; 41) BIND_PAT@[41; 44) NAME@[41; 44) diff --git a/tests/data/parser/inline/0044_ref_expr.txt b/tests/data/parser/inline/0044_ref_expr.txt index 65cdfb665..f4b553c56 100644 --- a/tests/data/parser/inline/0044_ref_expr.txt +++ b/tests/data/parser/inline/0044_ref_expr.txt @@ -20,7 +20,7 @@ FILE@[0; 52) EQ@[21; 22) REF_EXPR@[22; 25) WHITESPACE@[22; 23) - AMPERSAND@[23; 24) + AMP@[23; 24) LITERAL@[24; 25) INT_NUMBER@[24; 25) "1" SEMI@[25; 26) @@ -34,11 +34,11 @@ FILE@[0; 52) EQ@[37; 38) REF_EXPR@[38; 48) WHITESPACE@[38; 39) - AMPERSAND@[39; 40) + AMP@[39; 40) MUT_KW@[40; 43) REF_EXPR@[43; 48) WHITESPACE@[43; 44) - AMPERSAND@[44; 45) + AMP@[44; 45) CALL_EXPR@[45; 48) PATH_EXPR@[45; 46) PATH@[45; 46) diff --git a/tests/data/parser/inline/0054_impl_item_items.txt b/tests/data/parser/inline/0054_impl_item_items.txt index ee98619b4..f2aa2bd0e 100644 --- a/tests/data/parser/inline/0054_impl_item_items.txt +++ b/tests/data/parser/inline/0054_impl_item_items.txt @@ -65,7 +65,7 @@ FILE@[0; 89) PARAM_LIST@[76; 84) L_PAREN@[76; 77) SELF_PARAM@[77; 82) - AMPERSAND@[77; 78) + AMP@[77; 78) SELF_KW@[78; 82) R_PAREN@[82; 83) WHITESPACE@[83; 84) diff --git a/tests/data/parser/inline/0055_self_param.txt b/tests/data/parser/inline/0055_self_param.txt index 18760b7b6..6cf3151ea 100644 --- a/tests/data/parser/inline/0055_self_param.txt +++ b/tests/data/parser/inline/0055_self_param.txt @@ -33,7 +33,7 @@ FILE@[0; 106) PARAM_LIST@[35; 44) L_PAREN@[35; 36) SELF_PARAM@[36; 41) - AMPERSAND@[36; 37) + AMP@[36; 37) SELF_KW@[37; 41) COMMA@[41; 42) R_PAREN@[42; 43) @@ -50,7 +50,7 @@ FILE@[0; 106) PARAM_LIST@[55; 67) L_PAREN@[55; 56) SELF_PARAM@[56; 64) - AMPERSAND@[56; 57) + AMP@[56; 57) LIFETIME@[57; 59) "'a" WHITESPACE@[59; 60) SELF_KW@[60; 64) @@ -69,7 +69,7 @@ FILE@[0; 106) PARAM_LIST@[78; 101) L_PAREN@[78; 79) SELF_PARAM@[79; 91) - AMPERSAND@[79; 80) + AMP@[79; 80) LIFETIME@[80; 82) "'a" WHITESPACE@[82; 83) MUT_KW@[83; 86) diff --git a/tests/data/parser/inline/0062_deref_expr.txt b/tests/data/parser/inline/0062_deref_expr.txt index c7e61992a..5c6fe8ea5 100644 --- a/tests/data/parser/inline/0062_deref_expr.txt +++ b/tests/data/parser/inline/0062_deref_expr.txt @@ -17,7 +17,7 @@ FILE@[0; 23) DEREF_EXPR@[16; 19) STAR@[16; 17) REF_EXPR@[17; 19) - AMPERSAND@[17; 18) + AMP@[17; 18) LITERAL@[18; 19) INT_NUMBER@[18; 19) "1" SEMI@[19; 20) diff --git a/tests/data/parser/inline/0084_compound_ops.rs b/tests/data/parser/inline/0084_compound_ops.rs new file mode 100644 index 000000000..04b1764f1 --- /dev/null +++ b/tests/data/parser/inline/0084_compound_ops.rs @@ -0,0 +1,6 @@ +fn foo() { + x += 1; + 1 + 1 <= 2 * 3; + z -= 3 >= 0; + true || true && false; +} diff --git a/tests/data/parser/inline/0084_compound_ops.txt b/tests/data/parser/inline/0084_compound_ops.txt new file mode 100644 index 000000000..87492fe92 --- /dev/null +++ b/tests/data/parser/inline/0084_compound_ops.txt @@ -0,0 +1,89 @@ +FILE@[0; 89) + FN_ITEM@[0; 89) + FN_KW@[0; 2) + NAME@[2; 6) + WHITESPACE@[2; 3) + IDENT@[3; 6) "foo" + PARAM_LIST@[6; 9) + L_PAREN@[6; 7) + R_PAREN@[7; 8) + WHITESPACE@[8; 9) + BLOCK_EXPR@[9; 89) + L_CURLY@[9; 10) + EXPR_STMT@[10; 27) + BIN_EXPR@[10; 21) + PATH_EXPR@[10; 17) + PATH@[10; 17) + PATH_SEGMENT@[10; 17) + NAME_REF@[10; 17) + WHITESPACE@[10; 15) + IDENT@[15; 16) "x" + WHITESPACE@[16; 17) + PLUSEQ@[17; 19) + LITERAL@[19; 21) + WHITESPACE@[19; 20) + INT_NUMBER@[20; 21) "1" + SEMI@[21; 22) + WHITESPACE@[22; 27) + EXPR_STMT@[27; 47) + BIN_EXPR@[27; 41) + BIN_EXPR@[27; 33) + LITERAL@[27; 29) + INT_NUMBER@[27; 28) "1" + WHITESPACE@[28; 29) + PLUS@[29; 30) + LITERAL@[30; 33) + WHITESPACE@[30; 31) + INT_NUMBER@[31; 32) "1" + WHITESPACE@[32; 33) + LTEQ@[33; 35) + BIN_EXPR@[35; 41) + LITERAL@[35; 38) + WHITESPACE@[35; 36) + INT_NUMBER@[36; 37) "2" + WHITESPACE@[37; 38) + STAR@[38; 39) + LITERAL@[39; 41) + WHITESPACE@[39; 40) + INT_NUMBER@[40; 41) "3" + SEMI@[41; 42) + WHITESPACE@[42; 47) + EXPR_STMT@[47; 64) + BIN_EXPR@[47; 58) + PATH_EXPR@[47; 49) + PATH@[47; 49) + PATH_SEGMENT@[47; 49) + NAME_REF@[47; 49) + IDENT@[47; 48) "z" + WHITESPACE@[48; 49) + MINUSEQ@[49; 51) + BIN_EXPR@[51; 58) + LITERAL@[51; 54) + WHITESPACE@[51; 52) + INT_NUMBER@[52; 53) "3" + WHITESPACE@[53; 54) + GTEQ@[54; 56) + LITERAL@[56; 58) + WHITESPACE@[56; 57) + INT_NUMBER@[57; 58) "0" + SEMI@[58; 59) + WHITESPACE@[59; 64) + EXPR_STMT@[64; 87) + BIN_EXPR@[64; 85) + LITERAL@[64; 69) + TRUE_KW@[64; 68) + WHITESPACE@[68; 69) + PIPEPIPE@[69; 71) + BIN_EXPR@[71; 85) + LITERAL@[71; 77) + WHITESPACE@[71; 72) + TRUE_KW@[72; 76) + WHITESPACE@[76; 77) + AMPAMP@[77; 79) + LITERAL@[79; 85) + WHITESPACE@[79; 80) + FALSE_KW@[80; 85) + SEMI@[85; 86) + WHITESPACE@[86; 87) + R_CURLY@[87; 88) + WHITESPACE@[88; 89) diff --git a/tests/data/parser/inline/0084_loop_expr.rs b/tests/data/parser/inline/0084_loop_expr.rs new file mode 100644 index 000000000..9f078fa48 --- /dev/null +++ b/tests/data/parser/inline/0084_loop_expr.rs @@ -0,0 +1,3 @@ +fn foo() { + loop {}; +} diff --git a/tests/data/parser/inline/0084_loop_expr.txt b/tests/data/parser/inline/0084_loop_expr.txt new file mode 100644 index 000000000..858254380 --- /dev/null +++ b/tests/data/parser/inline/0084_loop_expr.txt @@ -0,0 +1,24 @@ +FILE@[0; 26) + FN_ITEM@[0; 26) + FN_KW@[0; 2) + NAME@[2; 6) + WHITESPACE@[2; 3) + IDENT@[3; 6) "foo" + PARAM_LIST@[6; 9) + L_PAREN@[6; 7) + R_PAREN@[7; 8) + WHITESPACE@[8; 9) + BLOCK_EXPR@[9; 26) + L_CURLY@[9; 10) + EXPR_STMT@[10; 24) + LOOP_EXPR@[10; 22) + WHITESPACE@[10; 15) + LOOP_KW@[15; 19) + BLOCK_EXPR@[19; 22) + WHITESPACE@[19; 20) + L_CURLY@[20; 21) + R_CURLY@[21; 22) + SEMI@[22; 23) + WHITESPACE@[23; 24) + R_CURLY@[24; 25) + WHITESPACE@[25; 26) -- cgit v1.2.3