PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/org/ooc/frontend/model/tokens/TokenReader.java

http://github.com/nddrylliog/ooc
Java | 36 lines | 28 code | 8 blank | 0 comment | 4 complexity | 765db9915aa0021a5f8418d860b4b4c7 MD5 | raw file
 1package org.ooc.frontend.model.tokens;
 2
 3import java.util.List;
 4
 5import org.ooc.frontend.model.tokens.Token.TokenType;
 6
 7public class TokenReader extends ListReader<Token> {
 8
 9	public TokenReader(List<Token> list) {
10		super(list);
11	}
12
13	public boolean skipWhitespace() {
14		boolean result = false;
15		while(hasNext() && peek().type == TokenType.LINESEP) {
16			skip();
17			result = true;
18		}
19		return result;
20	}
21	
22	public Token peekWhiteless() {
23		int index2 = index;
24		while(list.get(index2).type == TokenType.LINESEP) {
25			index2++;
26			if(index2 >= length) return null;
27		}
28		return list.get(index2);
29	}
30	
31	public Token readWhiteless() {
32		skipWhitespace();
33		return hasNext() ? list.get(index++) : null;
34	}
35	
36}