Skip to content
Snippets Groups Projects
Commit 06e5906f authored by Nathan PERIER's avatar Nathan PERIER
Browse files

Added methods to check the type of a token easily

parent 52af1601
No related branches found
No related tags found
No related merge requests found
...@@ -27,4 +27,20 @@ public class TokenPeekIterator extends PeekIterator<Token> { ...@@ -27,4 +27,20 @@ public class TokenPeekIterator extends PeekIterator<Token> {
nextObject = lexer.hasNext() ? lexer.readNextSymbol() : new EofToken(); nextObject = lexer.hasNext() ? lexer.readNextSymbol() : new EofToken();
} }
public boolean nextIs(TokenType type) {
return next().getType() == type;
}
public boolean peekIs(TokenType type) {
return peek().getType() == type;
}
public boolean junkIf(TokenType type) {
if(peek().getType() == type) {
junk();
return true;
}
return false;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment