gt:       throw new ParseException();
context: /* 
   *  Copyright (C) 2000 - 2008 TagServlet Ltd
   *
   *  This file is part of Open BlueDragon (OpenBD) CFML Server Engine.
   *  
   *  OpenBD is free software: you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  Free Software Foundation,version 3.
   *  
   *  OpenBD is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
   *  
   *  You should have received a copy of the GNU General Public License
   *  along with OpenBD.  If not, see http://www.gnu.org/licenses/
   *  
   *  Additional permission under GNU GPL version 3 section 7
   *  
   *  If you modify this Program, or any covered work, by linking or combining 
   *  it with any of the JARS listed in the README.txt (or a modified version of 
   *  (that library), containing parts covered by the terms of that JAR, the 
   *  licensors of this Program grant you additional permission to convey the 
   *  resulting work. 
   *  README.txt @ http://www.openbluedragon.org/license/README.txt
   *  
   *  http://www.openbluedragon.org/
   */
  
  /* Generated By:JavaCC: Do not edit this line. selectSQLParser.java */
  package com.naryx.tagfusion.cfm.queryofqueries;
  
  import java.util.ArrayList;
  import java.util.List;
  
  
  public class selectSQLParser implements selectSQLParserConstants {
          private int expNo = 1;
  
  /*****************************************
   * THE QOQ LANGUAGE GRAMMAR STARTS HERE *
   *****************************************/
  
  /*
   * Program structuring syntax follows.
   * _prepared is the number of permitted paramExpressions [?'s] in the SELECT statement
   */
    final public selectStatement Program(int _maxParams) throws ParseException {
          selectStatement s;
          List colsReferenced = new ArrayList();
          List aliases = new ArrayList();
          qoqParamInfo _paramInfo = new qoqParamInfo( _maxParams );
      s = orderByExpression(colsReferenced, aliases, _paramInfo);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SEMICOLON:
        jj_consume_token(SEMICOLON);
        break;
      default:
        jj_la1[0] = jj_gen;
        ;
      }
      jj_consume_token(0);
                  s.setReferencedColumns( colsReferenced );
                  s.setAliases( aliases );
                  {if (true) return s;}
      throw new Error("Missing return statement in function");
    }
  
    final public selectStatement orderByExpression(List _colsReferenced, List _aliases, qoqParamInfo _paramInfo) throws ParseException {
          selectStatement e;
    Token t1,t2;
          List obl;
      e = unionExpression(_colsReferenced, _aliases, _paramInfo);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ORDER:
        t1 = jj_consume_token(ORDER);
        t2 = jj_consume_token(BY);
        obl = orderByList();
                          e.setOrderByList( obl );
        break;
      default:
        jj_la1[1] = jj_gen;
        ;
      }
            {if (true) return e;}
      throw new Error("Missing return statement in function");
    }
  
    final public selectStatement unionExpression(List _colsReferenced, List _aliases, qoqParamInfo _paramInfo) throws ParseException {
          selectStatement e, e2;
    Token t1;
          boolean all = false;
      e = groupByExpression(_colsReferenced, _aliases, _paramInfo);
      label_1:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case UNION:
          ;
          break;
        default:
          jj_la1[2] = jj_gen;
          break label_1;
        }
        t1 = jj_consume_token(UNION);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case ALL:
          jj_consume_token(ALL);
                                 all = true;
          break;
        default:
          jj_la1[3] = jj_gen;
          ;
        }
        e2 = groupByExpression(_colsReferenced, _aliases, _paramInfo);
                          e = new unionStatement( e, e2, all );
                          all = false;
      }
                  {if (true) return e;}
      throw new Error("Missing return statement in function");
    }
  
    final public selectStatement groupByExpression(List _colsReferenced, List _aliases, qoqParamInfo _paramInfo) throws ParseException {
          selectStatement e;
          condition c;
          List grpByList;
          List refdCols = new ArrayList();
      e = whereExpression(_colsReferenced, _aliases, _paramInfo);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case GROUP:
        jj_consume_token(GROUP);
        jj_consume_token(BY);
        grpByList = groupByList(_colsReferenced, _aliases, _paramInfo);
                          e.setGroupByList( grpByList );
                          if ( !e.validateGroupBy() ){
                                  {if (true) throw new ParseException( "Invalid select column. All columns in the select must be specified in the group by clause." );}
                          }
        break;
      default:
        jj_la1[4] = jj_gen;
        ;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case HAVING:
        jj_consume_token(HAVING);
        c = conditionExpression(refdCols, _aliases, _paramInfo);
                          e.setHavingCondition( c );
                          if ( !e.validateHaving( refdCols ) )
                                  {if (true) throw new ParseException( "Invalid HAVING clause. All columns referenced in the HAVING clause must be specified in the group by clause." );}
                          _colsReferenced.addAll( refdCols );
        break;
      default:
        jj_la1[5] = jj_gen;
        ;
      }
                  {if (true) return e;}
      throw new Error("Missing return statement in function");
    }
  
    final public selectStatement whereExpression(List _colsReferenced, List _aliases, qoqParamInfo _paramInfo) throws ParseException {
          selectStatement e;
          condition c;
    Token t1, t2, t3;
      e = fromExpression(_colsReferenced, _aliases, _paramInfo);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case WHERE:
        t1 = jj_consume_token(WHERE);
        c = conditionExpression(_colsReferenced, _aliases, _paramInfo);
                          e.setWhereCondition( c ); //e= new whereStatement( e, e2 );  
  
        break;
      default:
        jj_la1[6] = jj_gen;
        ;
      }
                  {if (true) return e;}
      throw new Error("Missing return statement in function");
    }
  
    final public selectStatement fromExpression(List _colsReferenced, List _aliases, qoqParamInfo _paramInfo) throws ParseException {
          selectStatement e;
          List v;
    Token t1;
      e = selectExpression(_colsReferenced, _aliases, _paramInfo);
      t1 = jj_consume_token(FROM);
      v = fromList();
                  e.setFromList( v );
                  {if (true) return e;}
      throw new Error("Missing return statement in function");
    }
  
    final public selectStatement selectExpression(List _colsReferenced, List _aliases, qoqParamInfo _paramInfo) throws ParseException {
          selectStatement e, e2;
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OPENPAREN:
        jj_consume_token(OPENPAREN);
        e = selectExpression(_colsReferenced, _aliases, _paramInfo);
        jj_consume_token(CLOSEPAREN);
        break;
      case SELECT:
        e = selectSpec(_colsReferenced, _aliases, _paramInfo);
        break;
      default:
        jj_la1[7] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                  {if (true) return e;}
      throw new Error("Missing return statement in function");
    }
  
    final public selectStatement selectSpec(List _colsReferenced, List _aliases, qoqParamInfo _paramInfo) throws ParseException {
          selectStatement e;
          List v;
    Token t1, t2;
          boolean distinct = false;
          boolean all = false;
      t1 = jj_consume_token(SELECT);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case DISTINCT:
      case ALL:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case ALL:
          jj_consume_token(ALL);
          break;
        case DISTINCT:
          jj_consume_token(DISTINCT);
                                         distinct = true;
          break;
        default:
          jj_la1[8] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
        break;
      default:
        jj_la1[9] = jj_gen;
        ;
      }
      v = selectList(_colsReferenced, _aliases, _paramInfo);
                  {if (true) return new selectStatement( v, distinct );}
      throw new Error("Missing return statement in function");
    }
  
    final public List selectList(List _colsReferenced, List _aliases, qoqParamInfo _paramInfo) throws ParseException {
          Token t1, t2;
          selectColumn sc;
          List selects = new ArrayList();
      sc = selectColumn(_colsReferenced, _aliases, _paramInfo);
                                                                       selects.add( sc );
      label_2:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case COMMA:
          ;
          break;
        default:
          jj_la1[10] = jj_gen;
          break label_2;
        }
        jj_consume_token(COMMA);
        sc = selectColumn(_colsReferenced, _aliases, _paramInfo);
                                                                           selects.add( sc );
      }
                  {if (true) return selects;}
      throw new Error("Missing return statement in function");
    }
  
    final public selectColumn selectColumn(List _colsReferenced, List _aliases, qoqParamInfo _paramInfo) throws ParseException {
          Token t1;
          Token t2 = null;
          String alias = null;
          expression exp;
          selectColumn sc = null;
      if (jj_2_1(7)) {
        t1 = jj_consume_token(ASTERISK);
                                                {if (true) return new selectColumn();}
      } else if (jj_2_2(7)) {
        t1 = identifier();
        jj_consume_token(DOT);
        t2 = jj_consume_token(ASTERISK);
                                  sc=new selectColumn( t1.image.toLowerCase(), t2.image.toLowerCase() );
                                  _colsReferenced.add( t1.image.toLowerCase() + "." + t2.image.toLowerCase() );
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case AS:
        case IDENTIFIER:
        case LBRACKET:
          alias = alias();
                                              sc.setAlias( alias ); _aliases.add( alias.toLowerCase() );
          break;
        default:
          jj_la1[11] = jj_gen;
          ;
        }
      } else if (jj_2_3(7)) {
        exp = expression(_colsReferenced, _aliases, _paramInfo);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case AS:
        case IDENTIFIER:
        case LBRACKET:
          alias = alias();
          break;
        default:
          jj_la1[12] = jj_gen;
          ;
        }
                                  if ( exp instanceof columnRef ){
                                          columnRef col = (columnRef) exp;
                                          if ( col.tableNamed ){
                                                  sc=new selectColumn( col.table, col.colName );
                                          }else{
                                                  sc=new selectColumn( col.colName );
                                          }
  
                                          if ( alias != null ){ sc.setAlias( alias ); _aliases.add( alias.toLowerCase() ); };
  
                                  }else{
                                          sc = new selectColumn( exp );
                                          if ( alias == null ){
                                          sc.setAlias( "column_" + ( expNo - 1 ) );
                                                  expNo++;
                                          }else{
                                          sc.setAlias( alias );
                                          _aliases.add( alias.toLowerCase() );
                                          }
                                  }
      } else if (jj_2_4(7)) {
        t1 = identifier();
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case DOT:
          jj_consume_token(DOT);
          t2 = identifier();
          break;
        default:
          jj_la1[13] = jj_gen;
          ;
        }
                                  if ( t2 != null ){
                                          sc=new selectColumn( t1.image.toLowerCase(), t2.image.toLowerCase() );
                                          _colsReferenced.add( t1.image.toLowerCase() + "." + t2.image.toLowerCase() );
                                  }else{
                                          sc=new selectColumn( t1.image.toLowerCase() );
                                          _colsReferenced.add( t1.image.toLowerCase() );
                                  }
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case AS:
        case IDENTIFIER:
        case LBRACKET:
          alias = alias();
                                              sc.setAlias( alias ); _aliases.add( alias.toLowerCase() );
          break;
        default:
          jj_la1[14] = jj_gen;
          ;
        }
      } else {
        jj_consume_token(-1);
  