diff options
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 | ||