Instructs the parser to start parsing the current buffer.

@throws EOFException if parsing fails.
436085
public void parse() throws EOFException {
        if (!startedStreaming && levelStack.isEmpty()) {
            readNextChar(null);

            switch (currentChar) {
                case (byte) 0xEF:
                    pushLevel(Mode.BOM);
                    break;
                case O_CURLY:
                    pushLevel(Mode.JSON_OBJECT);
                    break;
                case O_SQUARE:
                    pushLevel(Mode.JSON_ARRAY);
                    break;
                default:
                    throw new IllegalStateException("Only UTF-8 is supported");
            }

            startedStreaming = true;
        }

        while (true) {
            if (levelStack.isEmpty()) {
                return; //nothing more to do
            }

            JsonLevel currentLevel = levelStack.peek();
            switch (currentLevel.peekMode()) {
                case BOM:
                    readBOM();
                    break;
                case JSON_OBJECT:
                    readObject(currentLevel);
                    break;
                case JSON_ARRAY:
                    readArray(currentLevel);
                    break;
                case JSON_OBJECT_VALUE:
                case JSON_ARRAY_VALUE:
                case JSON_STRING_HASH_KEY:
                case JSON_STRING_VALUE:
                case JSON_BOOLEAN_TRUE_VALUE:
                case JSON_BOOLEAN_FALSE_VALUE:
                case JSON_NUMBER_VALUE:
                case JSON_NULL_VALUE:
                    readValue(currentLevel);
                    break;
            }
        }
    }
664242
def do_eof(self, line):
        """"""
        d1_cli.impl.util.print_info("")
        self.do_exit(line)
550945
public boolean startDecode() throws IOException {
        if(insideSOS) {
            throw new IllegalStateException("decode already started");
        }
        if(foundEOI) {
            return false;
        }

        decodeHeader();
        int m = getMarker();
        while(m != 0xD9) {  // EOI
            if(m == 0xDA) { // SOS
                processScanHeader();
                insideSOS = true;
                currentMCURow = 0;
                reset();
                return true;
            } else {
                processMarker(m);
            }
            m = getMarker();
        }

        foundEOI = true;
        return false;
    }
155241
private void fillBuffer() throws IOException {
        if (!endOfInput && (lastCoderResult == null || lastCoderResult.isUnderflow())) {
            encoderIn.compact();
            int position = encoderIn.position();
            // We don't use Reader#read(CharBuffer) here because it is more efficient
            // to write directly to the underlying char array (the default implementation
            // copies data to a temporary char array).
            int c = reader.read(encoderIn.array(), position, encoderIn.remaining());
            if (c == -1) {
                endOfInput = true;
            } else {
                encoderIn.position(position + c);
            }
            encoderIn.flip();
        }
        encoderOut.compact();
        lastCoderResult = encoder.encode(encoderIn, encoderOut, endOfInput);
        encoderOut.flip();
    }
327303
@Override
  public void init() {
    if (!getProcessContext().inheritsIO()) {
      newThread(String.format("Process [%d] Standard Out Reader", safeGetId()),
        newProcessStreamReader(getProcess().getInputStream())).start();

      if (!getProcessContext().isRedirectingErrorStream()) {
        newThread(String.format("Process [%d] Standard Error Reader", safeGetId()),
          newProcessStreamReader(getProcess().getErrorStream())).start();
      }
    }

    initialized.set(true);
  }
328510
private void refreshBuffer() throws IOException {
    if (output == null) {
      // We're writing to a single buffer.
      throw new OutOfSpaceException();
    }

    // Since we have an output stream, this is our buffer
    // and buffer offset == 0
    output.write(buffer, 0, position);
    position = 0;
  }
627970
public void read(ByteCodeParser in)
    throws IOException
  {
    int length = in.readInt();
    
    int exnCount = in.readShort();

    for (int i = 0; i < exnCount; i++) {
      int index = in.readShort();

      if (index == 0)
        _exceptions.add(null);
      
      _exceptions.add(in.getConstantPool().getClass(index).getName());
    }
  }
553716
public void initialize() throws ODataUnmarshallingException {
        LOG.info("Parser is initializing");
        try {
            JsonParser jsonParser = JSON_FACTORY.createParser(inputJson);

            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String token = jsonParser.getCurrentName();
                if (token != null) {
                    if (token.startsWith(ODATA)) {
                        processSpecialTags(jsonParser);
                    } else if (token.endsWith(ODATA_BIND)) {
                        processLinks(jsonParser);
                    } else {
                        process(jsonParser);
                    }
                }
            }
        } catch (IOException e) {
            throw new ODataUnmarshallingException("It is unable to unmarshall", e);
        }
    }
1131222
public void start() {
		if (LOG.isInfoEnabled()) {
			LOG.info("Esper statement [" + epl + "] being started");
		}

		this.epStatement.start();

		if (LOG.isInfoEnabled()) {
			LOG.info("Esper statement [" + epl + "] started");
		}
	}
28544
void parseDocument(
            final Reader reader, final int suggestedBufferSize,
            final IMarkupHandler handler, final ParseStatus status)
            throws ParseException {


        final long parsingStartTimeNanos = System.nanoTime();

        char[] buffer = null;

        try {

            handler.handleDocumentStart(parsingStartTimeNanos, 1, 1);

            int bufferSize = suggestedBufferSize;
            buffer = this.pool.allocateBuffer(bufferSize);

            int bufferContentSize = reader.read(buffer);

            boolean cont = (bufferContentSize != -1);

            status.offset = -1;
            status.line = 1;
            status.col = 1;
            status.inStructure = false;
            status.parsingDisabled = true;
            status.parsingDisabledLimitSequence = null;
            status.autoCloseRequired = null;
            status.autoCloseLimits = null;

            while (cont) {

                parseBuffer(buffer, 0, bufferContentSize, handler, status);

                int readOffset = 0;
                int readLen = bufferSize;

                if (status.offset == 0) {

                    if (bufferContentSize == bufferSize) {
                        // Buffer is not big enough, double it!

                        char[] newBuffer = null;
                        try {

                            bufferSize *= 2;

                            newBuffer = this.pool.allocateBuffer(bufferSize);
                            System.arraycopy(buffer, 0, newBuffer, 0, bufferContentSize);

                            this.pool.releaseBuffer(buffer);

                            buffer = newBuffer;

                        } catch (final Exception ignored) {
                            this.pool.releaseBuffer(newBuffer);
                        }

                    }

                    // it's possible for two reads to occur in a row and 1) read less than the bufferSize and 2)
                    // still not find the next tag/end of structure
                    readOffset = bufferContentSize;
                    readLen = bufferSize - readOffset;

                } else if (status.offset < bufferContentSize) {

                    System.arraycopy(buffer, status.offset, buffer, 0, bufferContentSize - status.offset);

                    readOffset = bufferContentSize - status.offset;
                    readLen = bufferSize - readOffset;

                    status.offset = 0;
                    bufferContentSize = readOffset;

                }

                final int read = reader.read(buffer, readOffset, readLen);
                if (read != -1) {
                    bufferContentSize = readOffset + read;
                } else {
                    cont = false;
                }

            }

            // Iteration done, now it's time to clean up in case we still have some text to be notified

            int lastLine = status.line;
            int lastCol = status.col;

            final int lastStart = status.offset;
            final int lastLen = bufferContentSize - lastStart;

            if (lastLen > 0) {

                if (status.inStructure) {
                    throw new ParseException(
                            "Incomplete structure: \"" + new String(buffer, lastStart, lastLen) + "\"", status.line, status.col);
                }

                handler.handleText(buffer, lastStart, lastLen, status.line, status.col);

                // As we have produced an additional text event, we need to fast-forward the
                // lastLine and lastCol position to include the last text structure.
                for (int i = lastStart; i < (lastStart + lastLen); i++) {
                    final char c = buffer[i];
                    if (c == '\n') {
                        lastLine++;
                        lastCol = 1;
                    } else {
                        lastCol++;
                    }

                }

            }

            final long parsingEndTimeNanos = System.nanoTime();
            handler.handleDocumentEnd(parsingEndTimeNanos, (parsingEndTimeNanos - parsingStartTimeNanos), lastLine, lastCol);

        } catch (final ParseException e) {
            throw e;
        } catch (final Exception e) {
            throw new ParseException(e);
        } finally {
            this.pool.releaseBuffer(buffer);
            try {
                reader.close();
            } catch (final Throwable ignored) {
                // This exception can be safely ignored
            }
        }

    }
1363
protected function onRead()
    {
        start:
        if ($this->getInputLength() < 5) {
            return;
        }
        /* @TODO: refactoring Binary::* to support direct buffer calls */
        $pct = $this->read(4096);
        $h = Binary::getDWord($pct);
        if ($h !== 0xFFFFFFFF) {
            $this->finish();
            return;
        }
        $type = Binary::getChar($pct);
        if (($type === Pool::S2A_INFO) || ($type === Pool::S2A_INFO_SOURCE)) {
            $result = self::parseInfo($pct, $type);
        } elseif ($type === Pool::S2A_PLAYER) {
            $result = self::parsePlayers($pct);
        } elseif ($type === Pool::S2A_SERVERQUERY_GETCHALLENGE) {
            $result = mb_orig_substr($pct, 0, 4);
            $pct = mb_orig_substr($pct, 5);
        } elseif ($type === Pool::S2A_PONG) {
            $result = true;
        } else {
            $result = null;
        }
        $this->onResponse->executeOne($this, $result);
        $this->checkFree();
        goto start;
    }
483133
@Override
	public void start () {
		if (semaphore == null) {
			semaphore = NonBlockingSemaphoreRepository.getSemaphore(name);
		}
		semaphoreAcquired = semaphore.acquire();
		super.start();
	}
146907
@Override
	public ContextTransformer parse() {
		push(new ContainerNode(0, 0));
		while (TokenType.EOF != tokenizer.next()) {
			parseToken();
		}
		return new ContextTransformer(pop());
	}
305313
public void run() {
        logger.trace("BlockingConsumer " + this + " starting data processing");

        int length;
        char cs[] = new char[256];
        Reader reader = pair.getReader();

        while (!stopRequested && !foundEOF) {
            try {
                logger.trace("BlockingConsumer " + this + " reading from reader");
                length = reader.read(cs); // blocking
            } catch (IOException ioe) {
                // The reader most likely closed on us.
                logger.warn("Caught an exception while reading: " + ioe);
                logger.debug("Assuming EOF");
                foundEOF = true;
                break;
            }

            if (length == -1) { //EOF
                logger.debug("BlockingConsumer " + this + " detected EOF");
                logger.trace("Remaining buffer: " + buffer.toString());
                foundEOF = true;
                break;
            }

            // don't modify the buffer while processing is happening
            // written as while loop to prevent spurious interrupts
            logger.trace("BlockingConsumer " + this + " waiting for synchronized access before appending");
            synchronized(this) { // this could be just before notify, I think
                if (logger.isDebugEnabled()) {
                    logger.debug("BlockingConsumer " + this + " appending " + length + " characters to the buffer");

                    // TODO: this replace operation is done a few places, perhaps utility class?
                    String print = new String(cs, 0, length);
                    print = print.replaceAll("\n", "\\\\n");
                    print = print.replaceAll("\r", "\\\\r");
                    logger.debug("Adding to buffer: " + print);

                    StringBuffer sb = new StringBuffer();
                    for (int i = 0; i < length; i++)
                        sb.append("," + ((int) cs[i]) );
                    logger.trace("Codes: " + sb.toString());
                }
                buffer.append(cs, 0, length); // thread safe

                /**
                 * TODO Trim down buffer.  This current method won't work if a resume comes in, since it's offset
                 * will be invalid once this delete method runs
                 *
                 * // since we only added one char, we should only have to remove one
                 * if (buffer.length() > BUFFERMAX)
                 *     buffer.delete(0, BUFFERMAX - buffer.length());
                 */

                logger.trace("BlockingConsumer " + this + " notifying listeners of buffer change");
                notify(); // seeing that we read something, wake people up

                // We explicitly call this after appending to the
                // buffer, just in case one of the BufferChangeLoggers
                // accidentally modifies the character buffer.
                notifyBufferChange(cs, length);
            } // end synchronized(this)
        } // end while loop

        logger.trace("BlockingConsumer " + this + " notifying listeners upon ceasing");
        synchronized(this) {
            notify();
        }

        if (stopRequested) {
            logger.debug("BlockingConsumer " + this + " stop requested");
            pair.close();
        }

        if (foundEOF)
            logger.debug("BlockingConsumer " + this + " found EOF to stop while loop");
    }

    /**
     * TODO: what if something came in between when we last checked and
     *       when this method is called
     *
     * @param timeout timeout in milliseconds
     */
    public void waitForBuffer(long timeout) {
        if (foundEOF) {
            logger.trace("BlockingConsumer " + this + " wanted to wait for buffer but found EOF");
            return;
        }

        logger.trace("BlockingConsumer " + this + " ynching on this to wait");
        logger.trace("BlockingConsumer " + this + " waiting for synchronized access before waiting");
        synchronized(this) {
            try {
                if (timeout > 0) {
                    logger.trace("BlockingConsumer " + this + " waiting for " + timeout + " msec for some additional event");
                    wait(timeout);
                } else {
                    logger.trace("BlockingConsumer " + this + " waiting forever for some additional event");
                    wait();
                }
            } catch (InterruptedException ie) {
                logger.trace("BlockingConsumer " + this + " woken up while waiting for buffer");
            }
        }
    }

    /**
     * TODO
     *
     * @return TODO
     */
    public String pause() {
        // TODO mark offset, so that it can be trimmed by resume coming in later
        String currentBuffer;
        currentBuffer = buffer.toString();
        return currentBuffer;
    }

    /**
     * Resume processing from the specified offset.
     *
     * @param offset the offset into the buffer (1-indexed) from which
     *               to start
     */
    public void resume(int offset) {
        if (offset < 0)
            return;

        synchronized(this) {
            logger.trace("BlockingConsumer " + this + " moving buffer up by " + offset);
            StringBuffer smaller = buffer.delete(0, offset); // + 1
        }
    }

    /**
     * A method to test the <code>BlockingConsumer</code> class independently.
     *
     * @param args command line arguments (none used)
     */
    public static void main(String args[]) throws Exception {
        final StringBuffer buffer = new StringBuffer("The lazy fox");

        Thread t1 = new Thread() {
            public void run() {
                synchronized(buffer) {
                    buffer.delete(0,4);
                    buffer.append(" in the middle");
                    System.err.println("Middle");
                    try {
                        Thread.sleep(4000);
                    } catch (Exception e) {}
                    buffer.append(" of fall");
                    System.err.println("Fall");
                }
            }
        };

        Thread t2 = new Thread() {
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (Exception e) {}
                buffer.append(" jump over the fence");
                System.err.println("Fence");
            }
        };

        t1.start();
        t2.start();

        t1.join();
        t2.join();

        System.err.println(buffer);
    }
}
724064
private void buffer() throws IOException {
        int remaining = buffer.length;
        while (remaining > 0) {
            int r = input.read(buffer, buffer.length - remaining, remaining);
            if (r <= 0) {
                // Not enough information to fill the buffer
                offset = 0;
                maxOffset = buffer.length - remaining;
                return;
            }
            remaining -= r;
        }
        maxOffset = buffer.length;
        offset = 0;
    }
1061750
@Override
  protected void initParser() throws MtasConfigException {
    super.initParser();
    if (config != null) {
      for (int i = 0; i < config.children.size(); i++) {
        MtasConfiguration current = config.children.get(i);
        if (current.name.equals(PENNTREEBANK_IGNORE)) {
          for (int j = 0; j < current.children.size(); j++) {
            if (current.children.get(j).name.equals(PENNTREEBANK_NODE)) {
              String nameVariable = current.children.get(j).attributes
                  .get(PENNTREEBANK_NODE_NAME);
              if (!nameVariable.isEmpty()) {
                ignoreNodes.add(nameVariable);
              }
            }
          }
        }
      }
    }
  }
700610
private void parse()
    {
        this.elements = new ArrayList<>();

        try {
            for (Tokenizer tokenizer = new Tokenizer(this.rawVersion); tokenizer.next();) {
                Element element = new Element(tokenizer);
                this.elements.add(element);
                if (element.getVersionType() != Type.STABLE) {
                    this.type = element.getVersionType();
                }
            }

            trimPadding(this.elements);
        } catch (Exception e) {
            // Make sure to never fail no matter what
            LOGGER.error("Failed to parse version [" + this.rawVersion + "]", e);
            this.elements.add(new Element(this.rawVersion));
        }
    }