Package org.apache.etch.compiler

Examples of org.apache.etch.compiler.Token


   * @param type
   * @return true if the type is an etch builtin type.
   */
  public boolean isBasicType(TypeRef type) {
   
    Token t = type.type();
   
    switch (t.kind)
    {
    case EtchGrammarConstants.VOID:
      return true;
    case EtchGrammarConstants.BOOLEAN:
      return true;
    case EtchGrammarConstants.BYTE:
      return true;
    case EtchGrammarConstants.SHORT:
      return true;
    case EtchGrammarConstants.INT:
      return true;
    case EtchGrammarConstants.LONG:
      return true;
    case EtchGrammarConstants.FLOAT:
      return true;
    case EtchGrammarConstants.DOUBLE:
      return true;
    case EtchGrammarConstants.STRING:
      return true;
    case EtchGrammarConstants.OBJECT:
      return true;

    // patch here. more generic approach needed.
    // currently, only taking care of Map, Set, List & Datetime
    case EtchGrammarConstants.ID:
      if ( t.toString().equals("Map") || t.toString().equals("List") ||
          t.toString().equals("Set") || t.toString().equals("Datetime") )
        return true;
    }
    return false;
  }
View Full Code Here


   * @return the fundamental native reference type for java.
   * so etch int -> java Integer, while etch string -> java String.
   */
  private String getRefTypeName( TypeRef type )
  {
    Token t = type.type();
    switch (t.kind)
    {
      case EtchGrammarConstants.VOID: return "void";
      case EtchGrammarConstants.BOOLEAN: return "boolean";
      case EtchGrammarConstants.BYTE: return "byte";
View Full Code Here

    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
    {
View Full Code Here

        "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 ) );
View Full Code Here

    if (reqMsg.getResultMessage() != null)
      return;
   
    Name rmName = reqMsg.getResultMessageName();

    Token rmType = new Token();
    rmType.kind = EtchGrammarConstants.VOID;
    rmType.image = "void";
    TypeRef rmTypeRef = new TypeRef( this, rmType );
   
    nameList.check( rmName );
View Full Code Here

    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 ) );
View Full Code Here

  @Override
  public String getTypeValue( TypeRef type, Token value )
  {
    // System.out.println( "getTypeValue called with: "+type+": "+value );
    Token t = type.type();
    switch (t.kind)
    {
      case EtchGrammarConstants.LONG:
        return value.image + "L";
      case EtchGrammarConstants.FLOAT:
View Full Code Here

   * while etch string -> python string.
   */
  @Override
  public String getNativeTypeName( TypeRef type )
  {
    Token t = type.type();
    switch (t.kind)
    {
      case EtchGrammarConstants.VOID:
        return "";
      case EtchGrammarConstants.BOOLEAN:
View Full Code Here

   *         etch_int32*, while etch string -> etch_string*.
   */
  public String getPointerTypeName(TypeRef type) {
    if (type.isArray())
      return "etch_arraytype*";
    Token t = type.type();

    switch (t.kind) {
    case EtchGrammarConstants.VOID:
      return "void*";
    case EtchGrammarConstants.BOOLEAN:
View Full Code Here

   * @return the fundamental native reference type for python. so etch int ->
   * python int?, while etch string -> python string.
   */
  private String getRefTypeName( TypeRef type )
  {
    Token t = type.type();
    switch (t.kind)
    {
      case EtchGrammarConstants.VOID:
        return "";
      case EtchGrammarConstants.BOOLEAN:
View Full Code Here

TOP

Related Classes of org.apache.etch.compiler.Token

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.