Skip to content

Commit 9053bcc

Browse files
committed
Make mbe compile with parser changes
1 parent 6fa6efe commit 9053bcc

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

crates/mbe/src/syntax_bridge.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub fn token_tree_to_syntax_node(
9595
parser::Step::Token { kind, n_input_tokens: n_raw_tokens } => {
9696
tree_sink.token(kind, n_raw_tokens)
9797
}
98+
parser::Step::FloatSplit { .. } => tree_sink.token(SyntaxKind::FLOAT_NUMBER, 1),
9899
parser::Step::Enter { kind } => tree_sink.start_node(kind),
99100
parser::Step::Exit => tree_sink.finish_node(),
100101
parser::Step::Error { msg } => tree_sink.error(msg.to_string()),

crates/mbe/src/tt_iter.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ impl<'a> TtIter<'a> {
140140

141141
let mut cursor = buffer.begin();
142142
let mut error = false;
143+
let mut float_splits = vec![];
143144
for step in tree_traversal.iter() {
144145
match step {
145146
parser::Step::Token { kind, mut n_input_tokens } => {
@@ -150,6 +151,10 @@ impl<'a> TtIter<'a> {
150151
cursor = cursor.bump_subtree();
151152
}
152153
}
154+
parser::Step::FloatSplit { .. } => {
155+
float_splits.push(cursor);
156+
cursor = cursor.bump_subtree();
157+
}
153158
parser::Step::Enter { .. } | parser::Step::Exit => (),
154159
parser::Step::Error { .. } => error = true,
155160
}
@@ -167,18 +172,17 @@ impl<'a> TtIter<'a> {
167172
if cursor.is_root() {
168173
while curr != cursor {
169174
if let Some(token) = curr.token_tree() {
170-
res.push(token);
175+
res.push(token.cloned());
171176
}
172177
curr = curr.bump();
173178
}
174179
}
175180
self.inner = self.inner.as_slice()[res.len()..].iter();
176181
let res = match res.len() {
177-
1 => Some(res[0].cloned()),
178-
0 => None,
182+
0 | 1 => res.pop(),
179183
_ => Some(tt::TokenTree::Subtree(tt::Subtree {
180184
delimiter: tt::Delimiter::unspecified(),
181-
token_trees: res.into_iter().map(|it| it.cloned()).collect(),
185+
token_trees: res,
182186
})),
183187
};
184188
ExpandResult { value: res, err }

crates/tt/src/buffer.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ enum Entry<'t, Span> {
1616
// Mimicking types from proc-macro.
1717
Subtree(Option<&'t TokenTree<Span>>, &'t Subtree<Span>, EntryId),
1818
Leaf(&'t TokenTree<Span>),
19-
// End entries contain a pointer to the entry from the containing
20-
// token tree, or None if this is the outermost level.
19+
/// End entries contain a pointer to the entry from the containing
20+
/// token tree, or [`None`] if this is the outermost level.
2121
End(Option<EntryPtr>),
2222
}
2323

@@ -226,7 +226,9 @@ impl<'a, Span> Cursor<'a, Span> {
226226
/// a cursor into that subtree
227227
pub fn bump_subtree(self) -> Cursor<'a, Span> {
228228
match self.entry() {
229-
Some(Entry::Subtree(_, _, _)) => self.subtree().unwrap(),
229+
Some(&Entry::Subtree(_, _, entry_id)) => {
230+
Cursor::create(self.buffer, EntryPtr(entry_id, 0))
231+
}
230232
_ => self.bump(),
231233
}
232234
}

0 commit comments

Comments
 (0)