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


   
    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

    if (hasExtends())
    {
      Named<?> n = parent().get( xtnds.name );

      if (n == null)
        throw new ParseException( String.format(
          "exception %s extends %s not defined at line %d",
          this.name(), xtnds.name(), xtnds.token.beginLine ) );
     
      if (!(n instanceof Except))
        throw new ParseException( String.format(
          "exception %s extends %s not an exception at line %d",
          this.name(), xtnds.name(), xtnds.token.beginLine ) );
     
      Except s = this;
      while (s != null && s.hasExtends())
      {
        s = s.getExtends();
        if (s == this)
          throw new ParseException( String.format(
            "exception %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(
            "exception %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

   * @throws ParseException
   */
  public void check( Name name ) throws ParseException
  {
    if (map.containsKey( name.name ))
      throw new ParseException( String.format(
        "duplicate name (%s) at line %d", name.name, name.token.beginLine ) );
  }
View Full Code Here

    super( name.name, name.token.beginLine );
    addType( Message.class );
    addType( Service.class );
   
    if (args.length != 1)
      throw new ParseException( String.format( "AsyncReceiver args length != 1" ) );
   
    Token arg = args[0];
    if (arg.kind != EtchGrammarConstants.ID)
      throw new ParseException( String.format( "AsyncReceiver arg should be identifier: "+arg.image ) );
   
    try
    {
      AsyncReceiverMode m = AsyncReceiverMode.valueOf( arg.image.toUpperCase() );
      if (m == AsyncReceiverMode.POOL)
      {
        System.out.printf(
          "WARNING: deprecated AsyncReceiver mode POOL should be changed to QUEUED at line %d\n",
          arg.beginLine );
        m = AsyncReceiverMode.QUEUED;
      }
      this.mode = m;
    }
    catch ( IllegalArgumentException e )
    {
      throw new ParseException( String.format(
        "AsyncReceiver arg should be one of: "+EnumSet.allOf( AsyncReceiverMode.class ) ) );
    }
  }
View Full Code Here

    super( name.name, name.token.beginLine );
    addType( Message.class );
    addType( Service.class );
   
    if (args.length > 1)
      throw new ParseException( String.format(
        "Oneway accepts one optional boolean argument at line %d",
        name.token.beginLine ) );
   
    if (args.length > 0)
    {
      Token arg = args[0];
      if (arg.kind != EtchGrammarConstants.TRUE &&
          arg.kind != EtchGrammarConstants.FALSE)
        throw new ParseException( String.format(
          "Oneway accepts one optional boolean argument at line %d",
          name.token.beginLine ) );
      oneway = Boolean.parseBoolean( arg.image );
    }
    else
View Full Code Here

    super( name.name, name.token.beginLine );
    addType( Message.class );
    addType( Service.class );
   
    if (args.length != 1)
      throw new ParseException( String.format( "args.length != 1" ) );
    Token arg = args[0];
    if (arg.kind != EtchGrammarConstants.INTEGER)
      throw new ParseException( String.format( "Timeout arg should be integer constant: "+arg.image ) );
    int v = Integer.parseInt( arg.image );
    if (v < 0)
      throw new ParseException( String.format( "Timeout arg should be integer constant >= 0: "+arg.image ) );
   
    this.timeout = v;
  }
View Full Code Here

    super( name.name, name.token.beginLine );
    addType( Message.class );
    addType( Service.class );
   
    if (args.length != 1)
      throw new ParseException( String.format( "Direction args length != 1" ) );
   
    Token arg = args[0];
    if (arg.kind != EtchGrammarConstants.ID)
      throw new ParseException( String.format( "Direction arg should be identifier: "+arg.image ) );
   
    try
    {
      this.md = MessageDirection.valueOf( arg.image.toUpperCase() );
    }
    catch ( IllegalArgumentException e )
    {
      throw new ParseException( String.format(
        "Direction arg should be one of: "+EnumSet.allOf( MessageDirection.class ) ) );
    }
  }
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.