Package etch.compiler

Examples of etch.compiler.ParseException


    {
      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

    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

  {
    super( name.name, name.token.beginLine );
    addType( Except.class );
   
    if (args.length > 1)
      throw new ParseException( String.format(
        "Unchecked 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(
          "Unchecked accepts one optional boolean argument at line %d",
          name.token.beginLine ) );
      unchecked = Boolean.parseBoolean( arg.image );
    }
    else
View Full Code Here

    super( name.name, name.token.beginLine );
    addType( Except.class );
    addType( Struct.class );
   
    if (args.length != 1)
      throw new ParseException( String.format(
        "ToString accepts one string argument at line %d",
        name.token.beginLine ) );
   
    Token arg = args[0];
    if (arg.kind != EtchGrammarConstants.STR)
      throw new ParseException( String.format(
        "ToString accepts one string argument at line %d",
        arg.beginLine ) );
   
    try
    {
      format = parse( arg.image );
    }
    catch ( IOException e )
    {
      throw new ParseException( String.format(
        "ToString: problem with format string at line %d: %s",
        arg.beginLine, e.getMessage() ) );
    }
  }
View Full Code Here

   
    // usage: @Extern(language, name, nameImport, serializer, serializerImport)
    // example: @Extern(java, "java.util.Date", "", "etch.bindings.java.util.DateSerializer", "")
   
    if (args.length != 5)
      throw new ParseException( String.format(
        "usage: @Extern(language, \"xname\", \"xnameImport\", \"serializer\", \"serializerImport\") at line %d",
        name.token.beginLine ) );
   
    language = args[0];
    xname = args[1];
    xnameImport = args[2];
    serializer = args[3];
    serializerImport = args[4];
   
    if (language.kind != EtchGrammarConstants.ID)
      throw new ParseException( String.format(
        "Extern expected language to be <ID> at line %d",
        language.beginLine ) );
   
    if (xname.kind != EtchGrammarConstants.STR)
      throw new ParseException( String.format(
        "Extern expected xname to be <STR> at line %d",
        xname.beginLine ) );
   
    if (xnameImport.kind != EtchGrammarConstants.STR)
      throw new ParseException( String.format(
        "Extern expected xnameImport to be <STR> at line %d",
        xnameImport.beginLine ) );
   
    if (serializer.kind != EtchGrammarConstants.STR)
      throw new ParseException( String.format(
        "Extern expected serializer to be <STR> at line %d",
        serializer.beginLine ) );
   
    if (serializerImport.kind != EtchGrammarConstants.STR)
      throw new ParseException( String.format(
        "Extern expected serializerImport to be <STR> at line %d",
        serializerImport.beginLine ) );
  }
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

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.