private QueryBuilderKraken parseMap(QueryBuilderKraken query)
  {
    boolean distinct = false;

    Token token = scanToken();

    if (token == Token.DISTINCT)
      distinct = true;
    else
      _token = token;

    ArrayList<ExprKraken> resultItems = new ArrayList<>();

    Token startToken = scanToken();
    String startLexeme = _lexeme;
    int startOffset = _parseIndex;

    while ((token = scanToken()) != null
        && token != Token.EOF 
        && token != Token.FROM) {
    }

    if (token != Token.FROM) { 
      throw error("expected FROM at '{0}'", token);
    }

    _query = query;

    String tableName = parseFrom();

    query.setTableName(tableName);
    
    token = scanToken();
    
    Token tailToken = token;
    int tailOffset = _parseIndex;

    _token = startToken;
    _parseIndex = startOffset;
    _lexeme = startLexeme;

    ExprKraken expr = parseSelectExpr();

    resultItems.add(expr);

    while ((token = scanToken()) == Token.COMMA) {
      expr = parseSelectExpr();

      resultItems.add(expr);
    }

    _token = tailToken;
    _parseIndex = tailOffset;

    token = scanToken();
    
    ExprKraken whereExpr = null;

    if (token == Token.WHERE) {
      // _andExpr.add(parseExpr());
      whereExpr = parseExpr();
    }
    else {
      _token = token;
    }

    ParamExpr []params = _params.toArray(new ParamExpr[_params.size()]);
    
    query.setWhereExpr(whereExpr);
    // query.setKelpExpr(whereKelp);
    query.setParams(params);

    for (int i = resultItems.size() - 1; i >= 0; i--) {
      ExprKraken subExpr = resultItems.get(i);
    }

    ExprKraken []resultArray
      = resultItems.toArray(new ExprKraken[resultItems.size()]);

    query.setResults(resultArray);
    
    token = scanToken();
    
    if (token != null 
        && token != Token.EOF
        && token != Token.LIMIT 
        && token != Token.OFFSET) {
      throw error("unexpected token at end '{0}'", token);
    }

    return query;
  }
private QueryBuilderKraken parseMap ( QueryBuilderKraken query ) { boolean distinct = false ; Token token = scanToken ( ) ; if ( token == Token . DISTINCT ) distinct = true ; else _token = token ; ArrayList < ExprKraken > resultItems = new ArrayList < > ( ) ; Token startToken = scanToken ( ) ; String startLexeme = _lexeme ; int startOffset = _parseIndex ; while ( ( token = scanToken ( ) ) != null && token != Token . EOF && token != Token . FROM ) { } if ( token != Token . FROM ) { throw error ( "expected FROM at '{0}'" , token ) ; } _query = query ; String tableName = parseFrom ( ) ; query . setTableName ( tableName ) ; token = scanToken ( ) ; Token tailToken = token ; int tailOffset = _parseIndex ; _token = startToken ; _parseIndex = startOffset ; _lexeme = startLexeme ; ExprKraken expr = parseSelectExpr ( ) ; resultItems . add ( expr ) ; while ( ( token = scanToken ( ) ) == Token . COMMA ) { expr = parseSelectExpr ( ) ; resultItems . add ( expr ) ; } _token = tailToken ; _parseIndex = tailOffset ; token = scanToken ( ) ; ExprKraken whereExpr = null ; if ( token == Token . WHERE ) { whereExpr = parseExpr ( ) ; } else { _token = token ; } ParamExpr [ ] params = _params . toArray ( new ParamExpr [ _params . size ( ) ] ) ; query . setWhereExpr ( whereExpr ) ; query . setParams ( params ) ; for ( int i = resultItems . size ( ) - 1 ; i >= 0 ; i -- ) { ExprKraken subExpr = resultItems . get ( i ) ; } ExprKraken [ ] resultArray = resultItems . toArray ( new ExprKraken [ resultItems . size ( ) ] ) ; query . setResults ( resultArray ) ; token = scanToken ( ) ; if ( token != null && token != Token . EOF && token != Token . LIMIT && token != Token . OFFSET ) { throw error ( "unexpected token at end '{0}'" , token ) ; } return query ; }
Parses the select.