aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/tt_cursor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src/tt_cursor.rs')
-rw-r--r--crates/ra_mbe/src/tt_cursor.rs46
1 files changed, 6 insertions, 40 deletions
diff --git a/crates/ra_mbe/src/tt_cursor.rs b/crates/ra_mbe/src/tt_cursor.rs
index 468276397..a69c006c7 100644
--- a/crates/ra_mbe/src/tt_cursor.rs
+++ b/crates/ra_mbe/src/tt_cursor.rs
@@ -1,5 +1,6 @@
1use crate::subtree_parser::Parser; 1use crate::{subtree_parser::Parser, ParseError};
2use crate::ParseError; 2
3use ra_parser::FragmentKind;
3use smallvec::{smallvec, SmallVec}; 4use smallvec::{smallvec, SmallVec};
4 5
5#[derive(Debug, Clone)] 6#[derive(Debug, Clone)]
@@ -98,44 +99,9 @@ impl<'a> TtCursor<'a> {
98 }) 99 })
99 } 100 }
100 101
101 pub(crate) fn eat_path(&mut self) -> Option<tt::TokenTree> { 102 pub(crate) fn eat_fragment(&mut self, fragment_kind: FragmentKind) -> Option<tt::TokenTree> {
102 let parser = Parser::new(&mut self.pos, self.subtree);
103 parser.parse_path()
104 }
105
106 pub(crate) fn eat_expr(&mut self) -> Option<tt::TokenTree> {
107 let parser = Parser::new(&mut self.pos, self.subtree);
108 parser.parse_expr()
109 }
110
111 pub(crate) fn eat_ty(&mut self) -> Option<tt::TokenTree> {
112 let parser = Parser::new(&mut self.pos, self.subtree);
113 parser.parse_ty()
114 }
115
116 pub(crate) fn eat_pat(&mut self) -> Option<tt::TokenTree> {
117 let parser = Parser::new(&mut self.pos, self.subtree);
118 parser.parse_pat()
119 }
120
121 pub(crate) fn eat_stmt(&mut self) -> Option<tt::TokenTree> {
122 let parser = Parser::new(&mut self.pos, self.subtree);
123 parser.parse_stmt()
124 }
125
126 pub(crate) fn eat_block(&mut self) -> Option<tt::TokenTree> {
127 let parser = Parser::new(&mut self.pos, self.subtree);
128 parser.parse_block()
129 }
130
131 pub(crate) fn eat_meta(&mut self) -> Option<tt::TokenTree> {
132 let parser = Parser::new(&mut self.pos, self.subtree);
133 parser.parse_meta()
134 }
135
136 pub(crate) fn eat_item(&mut self) -> Option<tt::TokenTree> {
137 let parser = Parser::new(&mut self.pos, self.subtree); 103 let parser = Parser::new(&mut self.pos, self.subtree);
138 parser.parse_item() 104 parser.parse_fragment(fragment_kind)
139 } 105 }
140 106
141 pub(crate) fn eat_lifetime(&mut self) -> Option<tt::TokenTree> { 107 pub(crate) fn eat_lifetime(&mut self) -> Option<tt::TokenTree> {
@@ -154,7 +120,7 @@ impl<'a> TtCursor<'a> {
154 let old_pos = self.pos; 120 let old_pos = self.pos;
155 let parser = Parser::new(&mut self.pos, self.subtree); 121 let parser = Parser::new(&mut self.pos, self.subtree);
156 122
157 let res = parser.parse_vis(); 123 let res = parser.parse_fragment(FragmentKind::Visibility);
158 if res.is_none() { 124 if res.is_none() {
159 self.pos = old_pos; 125 self.pos = old_pos;
160 } 126 }