Added validation while peeking.
[svjatoslav_commons.git] / src / main / java / eu / svjatoslav / commons / string / tokenizer / Tokenizer.java
index ba1590d..cd5e5c0 100755 (executable)
@@ -120,6 +120,14 @@ public class Tokenizer {
         return false;
     }
 
+    public void peekExpectNoneOf(String [] ... possibilities) throws InvalidSyntaxException {
+        TokenizerMatch nextToken = peekNextToken();
+
+        for (String[] possibility : possibilities)
+            if (possibility.equals(nextToken))
+                throw new InvalidSyntaxException("Not expected \"" + nextToken + "\" here.");
+    }
+
 
     public boolean sequenceMatches(final String sequence) {
         if ((currentIndex + sequence.length()) > source.length())