diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-17 06:10:29 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-17 06:10:29 +0100 |
commit | 0e35603069b4f3cee97641204b09d91fd723d01d (patch) | |
tree | 5ce7ba4ec6fbf9ce8a25bfe2877abc78dd4e9f45 /crates/ra_parser/src/lib.rs | |
parent | 546d9be2a7bf7b3942c125f922a01321aea6ad26 (diff) | |
parent | 57e4122b890d56c11f9d74c1bdfed40f186331a4 (diff) |
Merge #1157
1157: Add mbe stmt matcher r=matklad a=edwin0cheng
Add `stmt` matcher in `ra_mbe` , and added corresponding `stmt()` parser in `ra_syntax`.
This PR also help PR #1148 for `MarcoKind::Items` parsing.
Note:
* According [the book](https://doc.rust-lang.org/reference/macros-by-example.html), mbe `stmt` matcher will only match statement without the trailing semicolon
* `item` is a valid statement.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/lib.rs')
-rw-r--r-- | crates/ra_parser/src/lib.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crates/ra_parser/src/lib.rs b/crates/ra_parser/src/lib.rs index 56755c394..9133c1b8a 100644 --- a/crates/ra_parser/src/lib.rs +++ b/crates/ra_parser/src/lib.rs | |||
@@ -88,6 +88,11 @@ pub fn parse_pat(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { | |||
88 | parse_from_tokens(token_source, tree_sink, grammar::pattern); | 88 | parse_from_tokens(token_source, tree_sink, grammar::pattern); |
89 | } | 89 | } |
90 | 90 | ||
91 | /// Parse given tokens into the given sink as a statement | ||
92 | pub fn parse_stmt(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink, with_semi: bool) { | ||
93 | parse_from_tokens(token_source, tree_sink, |p| grammar::stmt(p, with_semi)); | ||
94 | } | ||
95 | |||
91 | /// A parsing function for a specific braced-block. | 96 | /// A parsing function for a specific braced-block. |
92 | pub struct Reparser(fn(&mut parser::Parser)); | 97 | pub struct Reparser(fn(&mut parser::Parser)); |
93 | 98 | ||