From 42da26e9597443812da5a59b3fa48bdcbf619666 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 17 Nov 2020 20:02:46 +0100 Subject: parser,syntax: Add separate parser for stmt with optional semicolon Adjusting `grammar::fragments::stmt` to Optional or Yes will break original functionality and tests. --- .../parser/fragments/stmt/err/0000_fn_call.rast | 1 - .../parser/fragments/stmt/err/0000_fn_call.rs | 1 - .../parser/fragments/stmt/err/0000_let_stmt.rast | 1 - .../parser/fragments/stmt/err/0000_let_stmt.rs | 1 - .../fragments/stmt/err/0000_macro_let_stmt.rast | 1 - .../fragments/stmt/err/0000_macro_let_stmt.rs | 1 - .../stmt/err/0000_macro_unterminated_let_stmt.rast | 1 - .../stmt/err/0000_macro_unterminated_let_stmt.rs | 1 - .../parser/fragments/stmt/ok/0000_fn_call.rast | 11 +++++++++++ .../parser/fragments/stmt/ok/0000_fn_call.rs | 1 + .../parser/fragments/stmt/ok/0000_let_stmt.rast | 12 ++++++++++++ .../parser/fragments/stmt/ok/0000_let_stmt.rs | 1 + .../fragments/stmt/ok/0000_macro_let_stmt.rast | 21 +++++++++++++++++++++ .../parser/fragments/stmt/ok/0000_macro_let_stmt.rs | 1 + .../stmt/ok/0000_macro_unterminated_let_stmt.rast | 21 +++++++++++++++++++++ .../stmt/ok/0000_macro_unterminated_let_stmt.rs | 1 + 16 files changed, 69 insertions(+), 8 deletions(-) delete mode 100644 crates/syntax/test_data/parser/fragments/stmt/err/0000_fn_call.rast delete mode 100644 crates/syntax/test_data/parser/fragments/stmt/err/0000_fn_call.rs delete mode 100644 crates/syntax/test_data/parser/fragments/stmt/err/0000_let_stmt.rast delete mode 100644 crates/syntax/test_data/parser/fragments/stmt/err/0000_let_stmt.rs delete mode 100644 crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_let_stmt.rast delete mode 100644 crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_let_stmt.rs delete mode 100644 crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_unterminated_let_stmt.rast delete mode 100644 crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_unterminated_let_stmt.rs create mode 100644 crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rast create mode 100644 crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rs create mode 100644 crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rast create mode 100644 crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rs create mode 100644 crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rast create mode 100644 crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rs create mode 100644 crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rast create mode 100644 crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rs (limited to 'crates/syntax/test_data') diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_fn_call.rast b/crates/syntax/test_data/parser/fragments/stmt/err/0000_fn_call.rast deleted file mode 100644 index 5df7507e2..000000000 --- a/crates/syntax/test_data/parser/fragments/stmt/err/0000_fn_call.rast +++ /dev/null @@ -1 +0,0 @@ -ERROR diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_fn_call.rs b/crates/syntax/test_data/parser/fragments/stmt/err/0000_fn_call.rs deleted file mode 100644 index a280f9a5c..000000000 --- a/crates/syntax/test_data/parser/fragments/stmt/err/0000_fn_call.rs +++ /dev/null @@ -1 +0,0 @@ -foo(); diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/err/0000_let_stmt.rast deleted file mode 100644 index 5df7507e2..000000000 --- a/crates/syntax/test_data/parser/fragments/stmt/err/0000_let_stmt.rast +++ /dev/null @@ -1 +0,0 @@ -ERROR diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/err/0000_let_stmt.rs deleted file mode 100644 index de8a7f1fc..000000000 --- a/crates/syntax/test_data/parser/fragments/stmt/err/0000_let_stmt.rs +++ /dev/null @@ -1 +0,0 @@ -let x = 10; diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_let_stmt.rast deleted file mode 100644 index 5df7507e2..000000000 --- a/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_let_stmt.rast +++ /dev/null @@ -1 +0,0 @@ -ERROR diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_let_stmt.rs deleted file mode 100644 index 075f30159..000000000 --- a/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_let_stmt.rs +++ /dev/null @@ -1 +0,0 @@ -m1!{ let a = 0; }; diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_unterminated_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_unterminated_let_stmt.rast deleted file mode 100644 index 5df7507e2..000000000 --- a/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_unterminated_let_stmt.rast +++ /dev/null @@ -1 +0,0 @@ -ERROR diff --git a/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_unterminated_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_unterminated_let_stmt.rs deleted file mode 100644 index 075f30159..000000000 --- a/crates/syntax/test_data/parser/fragments/stmt/err/0000_macro_unterminated_let_stmt.rs +++ /dev/null @@ -1 +0,0 @@ -m1!{ let a = 0; }; diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rast new file mode 100644 index 000000000..8c186da93 --- /dev/null +++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rast @@ -0,0 +1,11 @@ +EXPR_STMT@0..6 + CALL_EXPR@0..5 + PATH_EXPR@0..3 + PATH@0..3 + PATH_SEGMENT@0..3 + NAME_REF@0..3 + IDENT@0..3 "foo" + ARG_LIST@3..5 + L_PAREN@3..4 "(" + R_PAREN@4..5 ")" + SEMICOLON@5..6 ";" diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rs new file mode 100644 index 000000000..a280f9a5c --- /dev/null +++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_fn_call.rs @@ -0,0 +1 @@ +foo(); diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rast new file mode 100644 index 000000000..8ab38da21 --- /dev/null +++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rast @@ -0,0 +1,12 @@ +LET_STMT@0..11 + LET_KW@0..3 "let" + WHITESPACE@3..4 " " + IDENT_PAT@4..5 + NAME@4..5 + IDENT@4..5 "x" + WHITESPACE@5..6 " " + EQ@6..7 "=" + WHITESPACE@7..8 " " + LITERAL@8..10 + INT_NUMBER@8..10 "10" + SEMICOLON@10..11 ";" diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rs new file mode 100644 index 000000000..de8a7f1fc --- /dev/null +++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_let_stmt.rs @@ -0,0 +1 @@ +let x = 10; diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rast new file mode 100644 index 000000000..81d6df29a --- /dev/null +++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rast @@ -0,0 +1,21 @@ +EXPR_STMT@0..18 + MACRO_CALL@0..17 + PATH@0..2 + PATH_SEGMENT@0..2 + NAME_REF@0..2 + IDENT@0..2 "m1" + BANG@2..3 "!" + TOKEN_TREE@3..17 + L_CURLY@3..4 "{" + WHITESPACE@4..5 " " + LET_KW@5..8 "let" + WHITESPACE@8..9 " " + IDENT@9..10 "a" + WHITESPACE@10..11 " " + EQ@11..12 "=" + WHITESPACE@12..13 " " + INT_NUMBER@13..14 "0" + SEMICOLON@14..15 ";" + WHITESPACE@15..16 " " + R_CURLY@16..17 "}" + SEMICOLON@17..18 ";" diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rs new file mode 100644 index 000000000..075f30159 --- /dev/null +++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_let_stmt.rs @@ -0,0 +1 @@ +m1!{ let a = 0; }; diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rast b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rast new file mode 100644 index 000000000..81d6df29a --- /dev/null +++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rast @@ -0,0 +1,21 @@ +EXPR_STMT@0..18 + MACRO_CALL@0..17 + PATH@0..2 + PATH_SEGMENT@0..2 + NAME_REF@0..2 + IDENT@0..2 "m1" + BANG@2..3 "!" + TOKEN_TREE@3..17 + L_CURLY@3..4 "{" + WHITESPACE@4..5 " " + LET_KW@5..8 "let" + WHITESPACE@8..9 " " + IDENT@9..10 "a" + WHITESPACE@10..11 " " + EQ@11..12 "=" + WHITESPACE@12..13 " " + INT_NUMBER@13..14 "0" + SEMICOLON@14..15 ";" + WHITESPACE@15..16 " " + R_CURLY@16..17 "}" + SEMICOLON@17..18 ";" diff --git a/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rs b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rs new file mode 100644 index 000000000..075f30159 --- /dev/null +++ b/crates/syntax/test_data/parser/fragments/stmt/ok/0000_macro_unterminated_let_stmt.rs @@ -0,0 +1 @@ +m1!{ let a = 0; }; -- cgit v1.2.3