コード例 #1
0
 public Character next() {
   if (left.hasNext()) {
     return left.next();
   } else if (right.hasNext()) {
     return right.next();
   }
   throw new NoSuchElementException();
 }
コード例 #2
0
 public boolean hasNext() {
   while (next == null) {
     if (leftChar == null) {
       if (left.hasNext()) {
         leftChar = left.next();
       } else {
         break;
       }
     }
     if (right.hasNext()) {
       Character c = right.next();
       if (c == leftChar) {
         next = c;
       }
     } else {
       right.reset();
       leftChar = null;
     }
   }
   return next != null;
 }
コード例 #3
0
 @Override
 protected void visit(RENode.CharacterClass expr) throws RuntimeException {
   expr.getExpr().accept(this);
   for (int i = expr.getMin(); i > 0; i--) {
     if (solver.hasNext()) {
       char c = solver.next();
       current.resolvingExpression.append(c);
       current.buffer.append(c);
       solver.reset();
     } else {
       throw new UnsupportedOperationException("wtf?");
     }
   }
 }