Beispiel #1
0
 /**
  * Try to find a token that matches the lexeme in a give category.
  *
  * @param category The category of tokens to consider.
  * @param lexeme The lexeme to look for for.
  * @return A matching Kind or null.
  */
 public static Token.Kind matchingKind(Token.Category category, String lexeme) {
   boolean found = false;
   Collection<Token.Kind> catKinds = Token.Kind.getCategory(category);
   Iterator<Token.Kind> iterator = catKinds.iterator();
   Token.Kind curKind = null;
   while (!found && iterator.hasNext()) {
     curKind = iterator.next();
     if (curKind.matches(lexeme)) {
       found = true;
     }
   }
   return found ? curKind : null;
 }