diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-18 13:00:16 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-18 13:00:16 +0100 |
commit | 403cd78baee7e9c2410d04ca0304575e7bbab16d (patch) | |
tree | 9e7ff9215e3490169c63c12e03c2eb03ca59ba20 /crates/ra_parser | |
parent | 112fd0ec7d65b5f23865410fd3e188e761d97110 (diff) | |
parent | e944fd059de93f305d6a8c40cfac5ebe84548771 (diff) |
Merge #1161
1161: Add mbe 'item' matcher r=matklad a=edwin0cheng
Add `item` matcher in `ra_mbe` , and added corresponding `item()` parser in `ra_syntax`.
This PR also help PR #1148 for `Items` parsing.
And hopefully fix #1149 ?!
Co-authored-by: Edwin Cheng <[email protected]>
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 2c2f785d0..f8ed1299a 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -69,6 +69,10 @@ pub(crate) fn stmt(p: &mut Parser, with_semi: bool) { | |||
69 | expressions::stmt(p, with_semi) | 69 | expressions::stmt(p, with_semi) |
70 | } | 70 | } |
71 | 71 | ||
72 | pub(crate) fn item(p: &mut Parser) { | ||
73 | items::item_or_macro(p, true, items::ItemFlavor::Mod) | ||
74 | } | ||
75 | |||
72 | pub(crate) fn reparser( | 76 | pub(crate) fn reparser( |
73 | node: SyntaxKind, | 77 | node: SyntaxKind, |
74 | first_child: Option<SyntaxKind>, | 78 | first_child: Option<SyntaxKind>, |
diff --git a/crates/ra_parser/src/lib.rs b/crates/ra_parser/src/lib.rs index 9133c1b8a..11b5b9a75 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 an item | ||
97 | pub fn parse_item(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { | ||
98 | parse_from_tokens(token_source, tree_sink, grammar::item); | ||
99 | } | ||
100 | |||
96 | /// A parsing function for a specific braced-block. | 101 | /// A parsing function for a specific braced-block. |
97 | pub struct Reparser(fn(&mut parser::Parser)); | 102 | pub struct Reparser(fn(&mut parser::Parser)); |
98 | 103 | ||