diff options
author | Edwin Cheng <[email protected]> | 2019-04-19 11:30:43 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-04-19 11:30:43 +0100 |
commit | 8092b6487f301bf9219c55fc714744fa2616fb9a (patch) | |
tree | ea65ea5146b62c5505737c81c7026bae9973693d /crates/ra_parser | |
parent | ab0a96586fd54858106cb6ac112d61eb657426f6 (diff) |
Add block matcher
Diffstat (limited to 'crates/ra_parser')
-rw-r--r-- | crates/ra_parser/src/grammar.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/lib.rs | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index e1762633e..7bae0bc7b 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -95,6 +95,10 @@ pub(crate) fn stmt(p: &mut Parser, with_semi: bool) { | |||
95 | expressions::stmt(p, with_semi) | 95 | expressions::stmt(p, with_semi) |
96 | } | 96 | } |
97 | 97 | ||
98 | pub(crate) fn block(p: &mut Parser) { | ||
99 | expressions::block(p); | ||
100 | } | ||
101 | |||
98 | pub(crate) fn item(p: &mut Parser) { | 102 | pub(crate) fn item(p: &mut Parser) { |
99 | items::item_or_macro(p, true, items::ItemFlavor::Mod) | 103 | items::item_or_macro(p, true, items::ItemFlavor::Mod) |
100 | } | 104 | } |
diff --git a/crates/ra_parser/src/lib.rs b/crates/ra_parser/src/lib.rs index 0ea942b6e..1e6a00642 100644 --- a/crates/ra_parser/src/lib.rs +++ b/crates/ra_parser/src/lib.rs | |||
@@ -93,6 +93,11 @@ pub fn parse_stmt(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink, | |||
93 | parse_from_tokens(token_source, tree_sink, |p| grammar::stmt(p, with_semi)); | 93 | parse_from_tokens(token_source, tree_sink, |p| grammar::stmt(p, with_semi)); |
94 | } | 94 | } |
95 | 95 | ||
96 | /// Parse given tokens into the given sink as a block | ||
97 | pub fn parse_block(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { | ||
98 | parse_from_tokens(token_source, tree_sink, grammar::block); | ||
99 | } | ||
100 | |||
96 | /// Parse given tokens into the given sink as an item | 101 | /// Parse given tokens into the given sink as an item |
97 | pub fn parse_item(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { | 102 | pub fn parse_item(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { |
98 | parse_from_tokens(token_source, tree_sink, grammar::item); | 103 | parse_from_tokens(token_source, tree_sink, grammar::item); |