blob: 8caeef9806439245dca88d3b9faf4c478dbac50f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package bjc.utils.parserutils.pratt;
import java.util.Iterator;
/**
* Simple implementation of token stream for strings.
*
* The terminal token here is represented by a token with type '(end)' and null
* value.
*
* @author EVE
*
*/
public class StringTokenStream implements TokenStream<String, String> {
private Iterator<Token<String, String>> iter;
private Token<String, String> curr;
/**
* Create a new token stream from a iterator.
*
* @param itr
* The iterator to use.
*
*/
public StringTokenStream(Iterator<Token<String, String>> itr) {
iter = itr;
}
@Override
public Token<String, String> current() {
return curr;
}
@Override
public void next() {
if(iter.hasNext()) {
curr = iter.next();
} else {
curr = new StringToken("(end)", null);
}
}
}
|