From 8092b6487f301bf9219c55fc714744fa2616fb9a Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 19 Apr 2019 18:30:43 +0800 Subject: Add block matcher --- crates/ra_parser/src/grammar.rs | 4 ++++ crates/ra_parser/src/lib.rs | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'crates/ra_parser') 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) { expressions::stmt(p, with_semi) } +pub(crate) fn block(p: &mut Parser) { + expressions::block(p); +} + pub(crate) fn item(p: &mut Parser) { items::item_or_macro(p, true, items::ItemFlavor::Mod) } 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, parse_from_tokens(token_source, tree_sink, |p| grammar::stmt(p, with_semi)); } +/// Parse given tokens into the given sink as a block +pub fn parse_block(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { + parse_from_tokens(token_source, tree_sink, grammar::block); +} + /// Parse given tokens into the given sink as an item pub fn parse_item(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { parse_from_tokens(token_source, tree_sink, grammar::item); -- cgit v1.2.3