|
1 |
| -use inflow::Inflow; |
| 1 | +use infinite_iterator::InfinitePeekable; |
2 | 2 | use source_files::{Source, SourceFileKey, SourceFiles};
|
3 | 3 | use std::{borrow::Borrow, fmt::Debug};
|
4 | 4 | use token::{Token, TokenKind};
|
5 | 5 |
|
6 |
| -pub struct Input<'a, I: Inflow<Token>> { |
| 6 | +pub struct Input<'a, I: InfinitePeekable<Token>> { |
7 | 7 | source_files: &'a SourceFiles,
|
8 |
| - inflow: I, |
| 8 | + infinite_peekable: I, |
9 | 9 | key: SourceFileKey,
|
10 | 10 | }
|
11 | 11 |
|
12 |
| -impl<'a, I: Inflow<Token>> Debug for Input<'a, I> { |
| 12 | +impl<'a, I: InfinitePeekable<Token>> Debug for Input<'a, I> { |
13 | 13 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
14 |
| - f.debug_struct("Input<Inflow<Token>>").finish() |
| 14 | + f.debug_struct("Input<InfiniteIterator<Token>>").finish() |
15 | 15 | }
|
16 | 16 | }
|
17 | 17 |
|
18 | 18 | impl<'a, I> Input<'a, I>
|
19 | 19 | where
|
20 |
| - I: Inflow<Token>, |
| 20 | + I: InfinitePeekable<Token>, |
21 | 21 | {
|
22 |
| - pub fn new(inflow: I, source_files: &'a SourceFiles, key: SourceFileKey) -> Self { |
| 22 | + pub fn new(infinite_peekable: I, source_files: &'a SourceFiles, key: SourceFileKey) -> Self { |
23 | 23 | Self {
|
24 |
| - inflow, |
| 24 | + infinite_peekable, |
25 | 25 | source_files,
|
26 | 26 | key,
|
27 | 27 | }
|
28 | 28 | }
|
29 | 29 |
|
30 | 30 | pub fn peek(&mut self) -> &Token {
|
31 |
| - self.inflow.peek_nth(0) |
| 31 | + self.infinite_peekable.peek_nth(0) |
32 | 32 | }
|
33 | 33 |
|
34 | 34 | pub fn peek_nth(&mut self, n: usize) -> &Token {
|
35 |
| - self.inflow.peek_nth(n) |
| 35 | + self.infinite_peekable.peek_nth(n) |
36 | 36 | }
|
37 | 37 |
|
38 | 38 | pub fn peek_n<const N: usize>(&mut self) -> [&Token; N] {
|
39 |
| - self.inflow.peek_n::<N>() |
| 39 | + self.infinite_peekable.peek_n::<N>() |
40 | 40 | }
|
41 | 41 |
|
42 | 42 | pub fn peek_is(&mut self, token: impl Borrow<TokenKind>) -> bool {
|
|
49 | 49 | }
|
50 | 50 |
|
51 | 51 | pub fn advance(&mut self) -> Token {
|
52 |
| - self.inflow.next() |
| 52 | + self.infinite_peekable.next() |
53 | 53 | }
|
54 | 54 |
|
55 | 55 | pub fn eat(&mut self, token: impl Borrow<TokenKind>) -> bool {
|
@@ -102,6 +102,6 @@ where
|
102 | 102 | // Adds input to the front of the queue,
|
103 | 103 | // useful for partially consuming tokens during parsing.
|
104 | 104 | pub fn unadvance(&mut self, token: Token) {
|
105 |
| - self.inflow.un_next(token) |
| 105 | + self.infinite_peekable.un_next(token) |
106 | 106 | }
|
107 | 107 | }
|
0 commit comments