Get the next token, raising an exception if it doesn't match one of
        the given kinds, or the input ends. If no kinds are given, returns the
        next token of any kind.
510645
def require(self, *kinds):
        """"""
        token = self.attempt()
        if not token:
            raise SyntaxError('Unexpected end of input')
        if kinds and token.kind not in kinds:
            raise SyntaxError.unexpected(token, kinds)
        return token
997294
def consume(self, kind):
        """"""
        next_token = self.stream.move()
        if next_token.kind != kind:
            raise UnexpectedTokenError(token=next_token, expected_kind=kind)
1307669
def _expect_token(lexer, types):
    """"""
    tok = next(lexer)
    if any(isinstance(tok, t) for t in types):
        return tok
    else:
        raise Error("unexpected token: " + str(tok))
618078
private int nextToken(StreamTokenizer tokeniser, Reader in, boolean ignoreEOF) throws IOException, ParserException {
        int token = tokeniser.nextToken();
        if (!ignoreEOF && token == StreamTokenizer.TT_EOF) {
            throw new ParserException("Unexpected end of file", getLineNumber(tokeniser, in));
        }
        return token;
    }
10600
private void nextToken(StreamTokenizer tokenizer) throws IOException {
    tokenizer.nextToken();
    if((tokenizer.ttype == '\'') || (tokenizer.ttype == '"')) {
      tokenizer.ttype = StreamTokenizer.TT_WORD;
    }
    else if((tokenizer.ttype == StreamTokenizer.TT_WORD) && (tokenizer.sval.equals("?"))) {
      tokenizer.ttype = '?';
    }
    if(LOG.isDebugging()) {
      if(tokenizer.ttype == StreamTokenizer.TT_NUMBER) {
        LOG.debug("token: " + tokenizer.nval);
      }
      else if(tokenizer.ttype == StreamTokenizer.TT_WORD) {
        LOG.debug("token: " + tokenizer.sval);
      }
      else if(tokenizer.ttype == StreamTokenizer.TT_EOF) {
        LOG.debug("token: EOF");
      }
      else if(tokenizer.ttype == StreamTokenizer.TT_EOL) {
        LOG.debug("token: EOL");
      }
      else {
        LOG.debug("token type: " + tokenizer.ttype);
      }
    }
  }
970875
private Token nextToken() {
        skipSpaces();
        if (hasNextChar()) {
            char ch = nextChar();
            if (Character.isJavaIdentifierStart(ch)) {
                StringBuffer buf = new StringBuffer();
                buf.append(ch);
                while ((ch = peekChar()) != -1
                        && Character.isJavaIdentifierPart(ch)) {
                    buf.append(ch);
                    nextChar();
                }
                return new Id(buf.toString());
            }

            if (ch == '\'' || ch == '"') {
                return parseQuotedChars(ch);
            } else {
                // For now...
                return new Char(ch);
            }
        }
        return null;
    }
1015494
protected LexToken readToken() throws LexException
	{
		LexToken tok = reader.getLast();
		reader.nextToken();
		return tok;
	}
1359074
@Override
    public Tuple getNext()
            throws IOException {
        Tuple tuple = null;
        try {
            if (isBuildingExample) {
                isBuildingExample = false; // Terminate on the next iteration
                return tupleFactory.newTuple(createPigExample());
            }

            boolean notDone = reader.nextKeyValue();
            if (!notDone) {
                return null;
            }

            ParsedRecord value = reader.getCurrentValue();

            if (value != null) {
                List<Object> values = new ArrayList<>();
                if (onlyWantListOfFields) {
                    values.add(value.getString(ApacheHttpdLogfileRecordReader.FIELDS));
                } else {
                    for (String fieldName : requestedFields) {
                        if (fieldName.endsWith(".*")) {
                            values.add(value.getStringSet(fieldName));
                            continue;
                        } else {
                            EnumSet<Casts> casts = reader.getParser().getCasts(fieldName);

                            if (casts != null) {
                                if (casts.contains(Casts.LONG)) {
                                    values.add(value.getLong(fieldName));
                                    continue;
                                }

                                if (casts.contains(Casts.DOUBLE)) {
                                    values.add(value.getDouble(fieldName));
                                    continue;
                                }
                            }
                        }
                        values.add(value.getString(fieldName));
                    }
                }
                tuple = tupleFactory.newTuple(values);
            }
        } catch (InvalidDissectorException | MissingDissectorsException e) {
            throw new IOException("Fatal error in the parser", e);
        }
        return tuple;
    }
1044597
public int nextToken() throws IOException
   {
      int c;
      int nextc = -1;
      boolean quoted = false;
      int result = m_next;
      if (m_next != 0)
      {
         m_next = 0;
      }

      m_buffer.setLength(0);

      while (result == 0)
      {
         if (nextc != -1)
         {
            c = nextc;
            nextc = -1;
         }
         else
         {
            c = read();
         }

         switch (c)
         {
            case TT_EOF:
            {
               if (m_buffer.length() != 0)
               {
                  result = TT_WORD;
                  m_next = TT_EOF;
               }
               else
               {
                  result = TT_EOF;
               }
               break;
            }

            case TT_EOL:
            {
               int length = m_buffer.length();

               if (length != 0 && m_buffer.charAt(length - 1) == '\r')
               {
                  --length;
                  m_buffer.setLength(length);
               }

               if (length == 0)
               {
                  result = TT_EOL;
               }
               else
               {
                  result = TT_WORD;
                  m_next = TT_EOL;
               }

               break;
            }

            default:
            {
               if (c == m_quote)
               {
                  if (quoted == false && startQuotedIsValid(m_buffer))
                  {
                     quoted = true;
                  }
                  else
                  {
                     if (quoted == false)
                     {
                        m_buffer.append((char) c);
                     }
                     else
                     {
                        nextc = read();
                        if (nextc == m_quote)
                        {
                           m_buffer.append((char) c);
                           nextc = -1;
                        }
                        else
                        {
                           quoted = false;
                        }
                     }
                  }
               }
               else
               {
                  if (c == m_delimiter && quoted == false)
                  {
                     result = TT_WORD;
                  }
                  else
                  {
                     m_buffer.append((char) c);
                  }
               }
            }
         }
      }

      m_type = result;

      return (result);
   }
514199
def next(self):
        """"""
        rv = self.current
        if self._pushed:
            self.current = self._pushed.popleft()
        elif self.current.type is not TOKEN_EOF:
            try:
                self.current = self._next()
            except StopIteration:
                self.close()
        return rv
771013
public final void nextToken() {
        skipIgnoredToken();
        if (isVariableBegin()) {
            currentToken = new Tokenizer(input, dictionary, offset).scanVariable();
        } else if (isNCharBegin()) {
            currentToken = new Tokenizer(input, dictionary, ++offset).scanChars();
        } else if (isIdentifierBegin()) {
            currentToken = new Tokenizer(input, dictionary, offset).scanIdentifier();
        } else if (isHexDecimalBegin()) {
            currentToken = new Tokenizer(input, dictionary, offset).scanHexDecimal();
        } else if (isNumberBegin()) {
            currentToken = new Tokenizer(input, dictionary, offset).scanNumber();
        } else if (isSymbolBegin()) {
            currentToken = new Tokenizer(input, dictionary, offset).scanSymbol();
        } else if (isCharsBegin()) {
            currentToken = new Tokenizer(input, dictionary, offset).scanChars();
        } else if (isEnd()) {
            currentToken = new Token(Assist.END, "", offset);
        } else {
            throw new SQLParsingException(this, Assist.ERROR);
        }
        offset = currentToken.getEndPosition();
    }
1366452
public Type readNextToken() throws IOException {
		int c;
		if (currentCharacter >= 0 && !Character.isWhitespace(currentCharacter)) {
			//there's still a character left from the last step
			c = currentCharacter;
			currentCharacter = -1;
		} else {
			//skip whitespace characters
			c = skipWhitespace();
		}
		if (c < 0) {
			return null;
		}
		
		//handle character
		if (c =='{') {
			currentTokenType = Type.START_OBJECT;
		} else if (c == '}') {
			currentTokenType = Type.END_OBJECT;
		} else if (c == '[') {
			currentTokenType = Type.START_ARRAY;
		} else if (c == ']') {
			currentTokenType = Type.END_ARRAY;
		} else if (c == ':') {
			currentTokenType = Type.COLON;
		} else if (c == ',') {
			currentTokenType = Type.COMMA;
		} else if (c == '"') {
			currentTokenType = Type.STRING;
		} else if (c == '-' || (c >= '0' && c<= '9')) {
			currentTokenType = Type.NUMBER;
			//the next token is a number. save the last character read because
			//readNumber() will need it.
			currentCharacter = c;
		} else if (c == 't') {
			int c2 = r.read();
			int c3 = r.read();
			int c4 = r.read();
			if (c2 == 'r' && c3 == 'u' & c4 == 'e') {
				currentTokenType = Type.TRUE;
			} else {
				currentTokenType = null;
			}
		} else if (c == 'f') {
			int c2 = r.read();
			int c3 = r.read();
			int c4 = r.read();
			int c5 = r.read();
			if (c2 == 'a' && c3 == 'l' & c4 == 's' && c5 == 'e') {
				currentTokenType = Type.FALSE;
			} else {
				currentTokenType = null;
			}
		} else if (c == 'n') {
			int c2 = r.read();
			int c3 = r.read();
			int c4 = r.read();
			if (c2 == 'u' && c3 == 'l' & c4 == 'l') {
				currentTokenType = Type.NULL;
			} else {
				currentTokenType = null;
			}
		} else {
			currentTokenType = null;
		}
		
		if (currentTokenType == null) {
			throw new IllegalStateException("Unrecognized token: " + (char)c);
		}
		
		return currentTokenType;
	}
149252
public Token next() throws IOException {
        skipWhitespace();
        int c = reader.read();
        if (c < 0) {
            return new Token(Token.EOF);
        } else if (c == '\n') {
            return new Token(Token.EOL);
        } else if (c == '\'' || c == '"') {
            return munchString(c);
        } else if (c == '/') {
            return maybeComment();
        } else if (single.get(c)) {
            return new Token(Token.SINGLE, String.valueOf((char) c));
        } else {
            reader.unread(c);
            return parseWord();
        }
    }
4134
def expect_optional_token(lexer: Lexer, kind: TokenKind) -> Optional[Token]:
    
    token = lexer.token
    if token.kind == kind:
        lexer.advance()
        return token

    return None
635602
@Override
    public String nextToken(String delim)
        throws NoSuchElementException
    {
        _delim=delim;
        _i=_lastStart;
        _token.setLength(0);
        _hasToken=false;
        return nextToken();
    }
870467
def _advance(self):
        
        cur_val = None if self.cur_token is None else self.cur_token.value
        try:
            self.cur_token = next(self._tokenizer)
        except StopIteration:
            self.cur_token = None
        return cur_val
1084467
private final void nextToken()
  {

    if (m_queueMark < m_ops.getTokenQueueSize())
    {
      m_token = (String) m_ops.m_tokenQueue.elementAt(m_queueMark++);
      m_tokenChar = m_token.charAt(0);
    }
    else
    {
      m_token = null;
      m_tokenChar = 0;
    }
  }