Package antlr

Examples of antlr.SemanticException


   * nodes and setting their expected type, if possible.
   */
  public void initialize() throws SemanticException {
    Node lhs = getLeftHandOperand();
    if ( lhs == null ) {
      throw new SemanticException( "left-hand operand of a binary operator was null" );
    }
    Node rhs = getRightHandOperand();
    if ( rhs == null ) {
      throw new SemanticException( "right-hand operand of a binary operator was null" );
    }

    Type lhsType = extractDataType( lhs );
    Type rhsType = extractDataType( rhs );

View Full Code Here


    if ( fetch && isSubQuery() ) {
      throw new QueryException( "fetch not allowed in subquery from-elements" );
    }
    // The path AST should be a DotNode, and it should have been evaluated already.
    if ( path.getType() != SqlTokenTypes.DOT ) {
      throw new SemanticException( "Path expected for join!" );
    }
    DotNode dot = ( DotNode ) path;
    int hibernateJoinType = JoinProcessor.toHibernateJoinType( joinType );
    dot.setJoinType( hibernateJoinType )// Tell the dot node about the join type.
    dot.setFetch( fetch );
    // Generate an explicit join for the root dot node.   The implied joins will be collected and passed up
    // to the root dot node.
    dot.resolve( true, false, alias == null ? null : alias.getText() );
    FromElement fromElement = dot.getImpliedJoin();
    fromElement.setAllPropertyFetch(propertyFetch!=null);

    if ( with != null ) {
      if ( fetch ) {
        throw new SemanticException( "with-clause not allowed on fetched associations; use filters" );
      }
      handleWithFragment( fromElement, with );
    }

    if ( log.isDebugEnabled() ) {
View Full Code Here

    }
    catch( InvalidWithClauseException e ) {
      throw e;
    }
    catch ( Exception e) {
      throw new SemanticException( e.getMessage() );
    }
  }
View Full Code Here

    }
  }

  protected AST generatePositionalParameter(AST inputNode) throws SemanticException {
    if ( namedParameters.size() > 0 ) {
      throw new SemanticException( "cannot define positional parameter after any named parameters have been defined" );
    }
    ParameterNode parameter = ( ParameterNode ) astFactory.create( PARAM, "?" );
    PositionalParameterSpecification paramSpec = new PositionalParameterSpecification(
        inputNode.getLine(),
            inputNode.getColumn(),
View Full Code Here

    FromClause fromClause = updateStatement.getFromClause();
    if ( versioned != null ) {
      // Make sure that the persister is versioned
      Queryable persister = fromClause.getFromElement().getQueryable();
      if ( !persister.isVersioned() ) {
        throw new SemanticException( "increment option specified for update of non-versioned entity" );
      }

      VersionType versionType = persister.getVersionType();
      if ( versionType instanceof UserVersionType ) {
        throw new SemanticException( "user-defined version types not supported for increment option" );
      }

      AST eq = getASTFactory().create( HqlSqlTokenTypes.EQ, "=" );
      AST versionPropertyNode = generateVersionPropertyNode( persister );
View Full Code Here

          if (f_AST == null) {
            if (filter) {
              f_AST = (AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(FROM,"{filter-implied FROM}")));
            }
            else
              throw new SemanticException("FROM expected (non-filter queries must contain a FROM clause)");
          }
           
          // Create an artificial token so the 'FROM' can be placed
          // before the SELECT in the tree to make tree processing
          // simpler.
View Full Code Here

      match(AS);
      path();
      a_AST = (AST)returnAST;
      match(CLOSE);
      if (!(i.getText().equalsIgnoreCase("treat") ))
        throw new SemanticException("i.getText().equalsIgnoreCase(\"treat\") ");
     
      registerTreat( p_AST, a_AST );
     
      castedJoinPath_AST = (AST)currentAST.root;
    }
View Full Code Here

      }
      else if ( "last".equalsIgnoreCase( nullPrecedence_AST.getText() ) ) {
      nullPrecedence_AST.setType( LAST );
      }
      else {
      throw new SemanticException( "Expecting 'first' or 'last', but found '" +  nullPrecedence_AST.getText() + "' as null ordering precedence." );
      }
     
      nullPrecedence_AST = (AST)currentAST.root;
    }
    catch (RecognitionException ex) {
View Full Code Here

      match(AS);
      path();
      a_AST = (AST)returnAST;
      match(CLOSE);
      if (!( i.getText().equals("treat") ))
        throw new SemanticException(" i.getText().equals(\"treat\") ");
     
      registerTreat( p_AST, a_AST );
     
      castedIdentPrimaryBase_AST = (AST)currentAST.root;
    }
View Full Code Here

    if ( fetch && isSubQuery() ) {
      throw new QueryException( "fetch not allowed in subquery from-elements" );
    }
    // The path AST should be a DotNode, and it should have been evaluated already.
    if ( path.getType() != SqlTokenTypes.DOT ) {
      throw new SemanticException( "Path expected for join!" );
    }
    DotNode dot = (DotNode) path;
    JoinType hibernateJoinType = JoinProcessor.toHibernateJoinType( joinType );
    dot.setJoinType( hibernateJoinType );    // Tell the dot node about the join type.
    dot.setFetch( fetch );
    // Generate an explicit join for the root dot node.   The implied joins will be collected and passed up
    // to the root dot node.
    dot.resolve( true, false, alias == null ? null : alias.getText() );

    final FromElement fromElement;
    if ( dot.getDataType() != null && dot.getDataType().isComponentType() ) {
      if ( dot.getDataType().isAnyType() ) {
        throw new SemanticException( "An AnyType attribute cannot be join fetched" );
        // ^^ because the discriminator (aka, the "meta columns") must be known to the SQL in
        //     a non-parameterized way.
      }
      FromElementFactory factory = new FromElementFactory(
          getCurrentFromClause(),
          dot.getLhs().getFromElement(),
          dot.getPropertyPath(),
          alias == null ? null : alias.getText(),
          null,
          false
      );
      fromElement = factory.createComponentJoin( (ComponentType) dot.getDataType() );
    }
    else {
      fromElement = dot.getImpliedJoin();
      fromElement.setAllPropertyFetch( propertyFetch != null );

      if ( with != null ) {
        if ( fetch ) {
          throw new SemanticException( "with-clause not allowed on fetched associations; use filters" );
        }
        handleWithFragment( fromElement, with );
      }
    }
View Full Code Here

TOP

Related Classes of antlr.SemanticException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.