Package etch.compiler

Examples of etch.compiler.ParseException


   * @throws ParseException
   */
  public Thrown addThrown( Name n ) throws ParseException
  {
    if (isOneway())
      throw new ParseException( String.format(
        "Oneway message cannot throw exception at line %d", n.token.beginLine ) );

    thrown.check( n );
    Thrown t = new Thrown( this, n );
    thrown.add( n, t );
View Full Code Here


    {
      if (i instanceof FieldItem)
      {
        FieldItem fi = (FieldItem) i;
        if (!hasParameter( fi.value() ))
          throw new ParseException( String.format(
            "ToString: format list specifies parameter (%s) which does not exist at line %d",
            fi.value(), lineno ) );
      }
    }
  }
View Full Code Here

    if (hasExtends())
    {
      Named<?> n = parent().get( xtnds.name );
     
      if (n == null)
        throw new ParseException( String.format(
          "struct %s extends %s not defined at line %d",
          this.name(), xtnds.name(), xtnds.token.beginLine ) );
     
      if (!(n instanceof Struct))
        throw new ParseException( String.format(
          "struct %s extends %s not a struct at line %d",
          this.name(), xtnds.name(), xtnds.token.beginLine ) );
     
      Struct s = this;
      while (s != null && s.hasExtends())
      {
        s = s.getExtends();
        if (s == this)
          throw new ParseException( String.format(
            "struct %s extends %s creates loop at line %d",
            this.name(), xtnds.name(), xtnds.token.beginLine ) );
      }
     
      s = getExtends();
      for (Parameter p: this)
      {
        Parameter x = s.getParameter( p.name().name );
        if (x != null)
          throw new ParseException( String.format(
            "struct %s extends %s hides parameter %s from %s at line %d",
            this.name(), xtnds.name(), x.name(), x.parent().name(),
            xtnds.token.beginLine ) );
      }
    }
View Full Code Here

  public void check( Class<?> type ) throws ParseException
  {
    if (types != null)
    {
      if (!types.contains( type ))
        throw new ParseException( String.format(
          "option %s not allowed here, line %d", this, lineno) );
    }
  }
View Full Code Here

      case EtchGrammarConstants.STRING:
        if (!isString( value ))
          incompatValueForType( type, value );
        break;
      default:
        throw new ParseException( "unknown type "+type.type() );
    }
  }
View Full Code Here

    }
  }

  private void incompatValueForType( TypeRef t, Token v ) throws ParseException
  {
    throw new ParseException( String.format(
      "incompatible value for type %s at line %d: %s",
      type.type(), value.beginLine, value ) );
  }
View Full Code Here

  public void check() throws ParseException
  {
    Named<?> n = getNamed();
   
    if (n == null)
      throw new ParseException( String.format(
        "undefined exception %s at line %d", name().token.image, name().token.beginLine ) );

    if (!(n instanceof Except))
      throw new ParseException( String.format(
        "%s not an exception at line %d", name().token.image, name().token.beginLine ) );
  }
View Full Code Here

   
    try
    {
      Module module = EtchCompiler.parseModule( this, n, nOpts );
      if (module == null)
        throw new ParseException( String.format(
          "could not find mixin '%s' at line %d",
          n.name, n.token.beginLine ) );
     
      Mixin mixin = new Mixin( this, n, nOpts, module );
      nameList.add( n, mixin );
      return mixin;
    }
    catch ( ParseException e )
    {
      throw e;
    }
    catch ( Exception e )
    {
      throw new ParseException( String.format(
        "could not find mixin '%s' at line %d: %s",
        n.name, n.token.beginLine, e ) );
    }
  }
View Full Code Here

    nameList.add( n, m );
   
    if (!m.isOneway())
      addResultMessage( m );
    else if (m.hasReturn())
      throw new ParseException( String.format(
        "Oneway message cannot have a non-void return type at line %d", n.token.beginLine ) );
   
    return m;
  }
View Full Code Here

      return;

    Named<?> n = getNamed( i );
   
    if (n == null)
      throw new ParseException( String.format(
        "undefined or ambiguous type %s at line %d", type.image, type.beginLine ) );

    if (n instanceof Enumx)
      return;
   
    if (n instanceof Struct)
      return;
   
    if (n instanceof Extern)
      return;
   
    if (n instanceof Builtin)
      return;
   
    throw new ParseException( String.format(
      "%s not a type at line %d", type.image, type.beginLine ) );
  }
View Full Code Here

TOP

Related Classes of etch.compiler.ParseException

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.