1
2
3
4
5
6
7
8
9
10
11
12 package org.hyphenType.lexerparser;
13
14 import java.util.List;
15
16 import org.hyphenType.datastructure.lexer.LexToken;
17
18
19
20
21 public class LexTokenStream {
22
23 private int index = 0;
24 private final List<LexToken> tokens;
25
26 public LexTokenStream(List<LexToken> tokens) {
27 this.tokens = tokens;
28 }
29
30 public boolean hasFutureToken() {
31 return tokens.size() > index;
32 }
33
34 public LexToken futureToken() {
35 return tokens.get(index);
36 }
37
38 public LexToken currentToken() {
39 if (index - 1 > -1)
40 return tokens.get(index - 1);
41 else
42 return null;
43 }
44
45 public LexToken consume() {
46 LexToken token = tokens.get(index);
47 index++;
48 return token;
49 }
50 }