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

Added method to require the presence of a token

parent 4c6ce7cc
No related branches found
No related tags found
No related merge requests found
...@@ -60,4 +60,22 @@ public class TokenPeekIterator implements PeekIterator<Token> { ...@@ -60,4 +60,22 @@ public class TokenPeekIterator implements PeekIterator<Token> {
return false; return false;
} }
public void expect(TokenType type) {
if(!peekIs(type)) {
throw new ParsingException("Expected " + type + ", got " + peek(), peek());
}
}
public void expect(TokenType type, String where) {
if(!peekIs(type)) {
throw new ParsingException("Expected " + type + " in " + where + ", got " + peek(), peek());
}
}
public void expectJunk(TokenType type) {
if(!junkIf(type)) {
throw new ParsingException("Expected " + type + ", got " + peek(), peek());
}
}
} }
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