From bc99e95d7d954701c36142881302bb70e791bec1 Mon Sep 17 00:00:00 2001 From: David Lattimore Date: Fri, 19 Jun 2020 07:43:19 +1000 Subject: Implement APIs for parsing expressions, types, paths, patterns and items --- .../fragments/expr/err/0000_truncated_add.rast | 1 + .../fragments/expr/err/0000_truncated_add.rs | 1 + .../parser/fragments/expr/ok/0000_add.rast | 8 ++++++++ .../test_data/parser/fragments/expr/ok/0000_add.rs | 1 + .../fragments/item/err/0000_extra_keyword.rast | 1 + .../fragments/item/err/0000_extra_keyword.rs | 1 + .../parser/fragments/item/ok/0000_fn.rast | 12 ++++++++++++ .../test_data/parser/fragments/item/ok/0000_fn.rs | 1 + .../fragments/path/err/0000_reserved_word.rast | 1 + .../fragments/path/err/0000_reserved_word.rs | 1 + .../parser/fragments/path/err/0001_expression.rast | 1 + .../parser/fragments/path/err/0001_expression.rs | 1 + .../fragments/path/ok/0000_single_ident.rast | 4 ++++ .../parser/fragments/path/ok/0000_single_ident.rs | 1 + .../parser/fragments/path/ok/0001_multipart.rast | 14 ++++++++++++++ .../parser/fragments/path/ok/0001_multipart.rs | 1 + .../fragments/pattern/err/0000_reserved_word.rast | 1 + .../fragments/pattern/err/0000_reserved_word.rs | 1 + .../fragments/pattern/err/0001_missing_paren.rast | 1 + .../fragments/pattern/err/0001_missing_paren.rs | 1 + .../parser/fragments/pattern/ok/0000_enum.rast | 10 ++++++++++ .../parser/fragments/pattern/ok/0000_enum.rs | 1 + .../fragments/type/err/0000_missing_close.rast | 1 + .../fragments/type/err/0000_missing_close.rs | 1 + .../parser/fragments/type/ok/0000_result.rast | 22 ++++++++++++++++++++++ .../parser/fragments/type/ok/0000_result.rs | 1 + 26 files changed, 90 insertions(+) create mode 100644 crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rs create mode 100644 crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rast create mode 100644 crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rs (limited to 'crates/ra_syntax/test_data/parser/fragments') diff --git a/crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rast b/crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rast new file mode 100644 index 000000000..5df7507e2 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rast @@ -0,0 +1 @@ +ERROR diff --git a/crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rs b/crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rs new file mode 100644 index 000000000..ca49acb07 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rs @@ -0,0 +1 @@ +1 + diff --git a/crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rast b/crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rast new file mode 100644 index 000000000..fa78a02a6 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rast @@ -0,0 +1,8 @@ +BIN_EXPR@0..5 + LITERAL@0..1 + INT_NUMBER@0..1 "1" + WHITESPACE@1..2 " " + PLUS@2..3 "+" + WHITESPACE@3..4 " " + LITERAL@4..5 + INT_NUMBER@4..5 "2" diff --git a/crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rs b/crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rs new file mode 100644 index 000000000..e0ef58402 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rs @@ -0,0 +1 @@ +1 + 2 diff --git a/crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rast b/crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rast new file mode 100644 index 000000000..5df7507e2 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rast @@ -0,0 +1 @@ +ERROR diff --git a/crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rs b/crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rs new file mode 100644 index 000000000..dc32389bb --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rs @@ -0,0 +1 @@ +fn fn foo() {} diff --git a/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast b/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast new file mode 100644 index 000000000..f1e78f388 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast @@ -0,0 +1,12 @@ +FN_DEF@0..11 + FN_KW@0..2 "fn" + 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..11 + L_CURLY@9..10 "{" + R_CURLY@10..11 "}" diff --git a/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rs b/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rs new file mode 100644 index 000000000..8f3b7ef11 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rs @@ -0,0 +1 @@ +fn foo() {} diff --git a/crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rast b/crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rast new file mode 100644 index 000000000..5df7507e2 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rast @@ -0,0 +1 @@ +ERROR diff --git a/crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rs b/crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rs new file mode 100644 index 000000000..2046de049 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rs @@ -0,0 +1 @@ +struct diff --git a/crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rast b/crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rast new file mode 100644 index 000000000..5df7507e2 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rast @@ -0,0 +1 @@ +ERROR diff --git a/crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rs b/crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rs new file mode 100644 index 000000000..745e8d376 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rs @@ -0,0 +1 @@ +a + b diff --git a/crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rast b/crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rast new file mode 100644 index 000000000..0c5d4360f --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rast @@ -0,0 +1,4 @@ +PATH@0..3 + PATH_SEGMENT@0..3 + NAME_REF@0..3 + IDENT@0..3 "foo" diff --git a/crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rs b/crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rs new file mode 100644 index 000000000..257cc5642 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rs @@ -0,0 +1 @@ +foo diff --git a/crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rast b/crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rast new file mode 100644 index 000000000..4a2b45e6a --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rast @@ -0,0 +1,14 @@ +PATH@0..13 + PATH@0..8 + PATH@0..3 + PATH_SEGMENT@0..3 + NAME_REF@0..3 + IDENT@0..3 "foo" + COLON2@3..5 "::" + PATH_SEGMENT@5..8 + NAME_REF@5..8 + IDENT@5..8 "bar" + COLON2@8..10 "::" + PATH_SEGMENT@10..13 + NAME_REF@10..13 + IDENT@10..13 "baz" diff --git a/crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rs b/crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rs new file mode 100644 index 000000000..81e0b21cd --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rs @@ -0,0 +1 @@ +foo::bar::baz diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rast b/crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rast new file mode 100644 index 000000000..5df7507e2 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rast @@ -0,0 +1 @@ +ERROR diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rs b/crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rs new file mode 100644 index 000000000..ae26fc455 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rs @@ -0,0 +1 @@ +fn diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rast b/crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rast new file mode 100644 index 000000000..5df7507e2 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rast @@ -0,0 +1 @@ +ERROR diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rs b/crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rs new file mode 100644 index 000000000..61a391d08 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rs @@ -0,0 +1 @@ +Some(x diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast b/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast new file mode 100644 index 000000000..15eb7f9c6 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast @@ -0,0 +1,10 @@ +TUPLE_STRUCT_PAT@0..7 + PATH@0..4 + PATH_SEGMENT@0..4 + NAME_REF@0..4 + IDENT@0..4 "Some" + L_PAREN@4..5 "(" + BIND_PAT@5..6 + NAME@5..6 + IDENT@5..6 "x" + R_PAREN@6..7 ")" diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rs b/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rs new file mode 100644 index 000000000..87114dd78 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rs @@ -0,0 +1 @@ +Some(x) diff --git a/crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rast b/crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rast new file mode 100644 index 000000000..5df7507e2 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rast @@ -0,0 +1 @@ +ERROR diff --git a/crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rs b/crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rs new file mode 100644 index 000000000..caa4d7c09 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rs @@ -0,0 +1 @@ +Result" diff --git a/crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rs b/crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rs new file mode 100644 index 000000000..b50b3bb3b --- /dev/null +++ b/crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rs @@ -0,0 +1 @@ +Result -- cgit v1.2.3