aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-04-19 11:30:43 +0100
committerEdwin Cheng <[email protected]>2019-04-19 11:30:43 +0100
commit8092b6487f301bf9219c55fc714744fa2616fb9a (patch)
treeea65ea5146b62c5505737c81c7026bae9973693d /crates/ra_parser
parentab0a96586fd54858106cb6ac112d61eb657426f6 (diff)
Add block matcher
Diffstat (limited to 'crates/ra_parser')
-rw-r--r--crates/ra_parser/src/grammar.rs4
-rw-r--r--crates/ra_parser/src/lib.rs5
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
98pub(crate) fn block(p: &mut Parser) {
99 expressions::block(p);
100}
101
98pub(crate) fn item(p: &mut Parser) { 102pub(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
97pub 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
97pub fn parse_item(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { 102pub 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);