Merge branch 'minas' into abecker/charj-main
authorAaron Becker <akbecker@gmail.com>
Wed, 26 May 2010 06:58:54 +0000 (01:58 -0500)
committerAaron Becker <akbecker@gmail.com>
Wed, 26 May 2010 06:58:54 +0000 (01:58 -0500)
1  2 
src/langs/charj/src/charj/translator/CharjSemantics.g

index f3b61174717b4e15b27117d48cf227269edd01ac,e51d637ac96aaa723ea3d82f656e8dbac8dab231..2ec7de47f4b2c9ddf1977a99ca7da9ae1e3cfc73
@@@ -172,25 -172,11 +172,25 @@@ scope ScopeStack
              currentClass.define($IDENT.text, sym);
              $FUNCTION_METHOD_DECL.symbol = sym;
          }
 -    |   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList)
 -    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList)
 +    |   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType
 +            ^(VAR_DECLARATOR_LIST field[$simpleType.type]+))
 +    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType
 +            ^(VAR_DECLARATOR_LIST field[$objectType.type]+))
      |   ^(CONSTRUCTOR_DECL m=modifierList? g=genericTypeParameterList? IDENT f=formalParameterList 
              b=block)
      ;
 +
 +field [ClassSymbol type]
 +    :   ^(VAR_DECLARATOR ^(IDENT arrayDeclaratorList?) variableInitializer?)
 +    {
 +            //System.out.println("Found variable: " + $type + " " + $IDENT.text);
 +            //VariableSymbol sym = new VariableSymbol(symtab, $IDENT.text, $type);
 +            //sym.definition = $field.start;
 +            //sym.definitionTokenStream = input.getTokenStream();
 +            //$VAR_DECLARATOR.symbol = sym;
 +            //currentClass.define($IDENT.text, sym);
 +    }
 +    ;
      
  interfaceScopeDeclaration
      :   ^(FUNCTION_METHOD_DECL modifierList? genericTypeParameterList? 
@@@ -207,8 -193,7 +207,8 @@@ variableDeclaratorLis
      ;
  
  variableDeclarator
 -    :   ^(VAR_DECLARATOR variableDeclaratorId variableInitializer?)
 +    :   ^(VAR_DECLARATOR ^(IDENT arrayDeclaratorList?) variableInitializer?)
 +
      ;
      
  variableDeclaratorId
@@@ -270,36 -255,22 +270,36 @@@ typ
      |   VOID
      ;
  
 -simpleType
 +simpleType returns [ClassSymbol type]
      :   ^(SIMPLE_TYPE primitiveType arrayDeclaratorList?)
 +        {
 +            $type = symtab.resolveBuiltinType($primitiveType.text);
 +        }
      ;
      
 -objectType
 +objectType returns [ClassSymbol type]
      :   ^(OBJECT_TYPE qualifiedTypeIdent arrayDeclaratorList?)
      |   ^(REFERENCE_TYPE qualifiedTypeIdent arrayDeclaratorList?)
      |   ^(POINTER_TYPE qualifiedTypeIdent arrayDeclaratorList?)
 +        {
 +            /*
 +            System.out.println("Resolving type: " + $qualifiedTypeIdent.name);
 +            $type = currentClass.resolveType($qualifiedTypeIdent.name);
 +            if ($type == null) $type = symtab.resolveBuiltinType($qualifiedTypeIdent.name);
 +            */
 +        }
      ;
  
 -qualifiedTypeIdent
 -    :   ^(QUALIFIED_TYPE_IDENT typeIdent+) 
 +qualifiedTypeIdent returns [String name]
 +@init {
 +$name = "";
 +}
 +    :   ^(QUALIFIED_TYPE_IDENT (typeIdent {$name += $typeIdent.name;})+) 
      ;
  
 -typeIdent
 +typeIdent returns [String name]
      :   ^(IDENT genericTypeArgumentList?)
 +        { $name = $IDENT.text; }
      ;
  
  primitiveType
@@@ -487,7 -458,7 +487,7 @@@ newExpressio
              |   genericTypeArgumentList? qualifiedTypeIdent newArrayConstruction
              )
          )
-     |   ^('new' qualifiedTypeIdent arguments)
+     |   ^(NEW qualifiedTypeIdent arguments)
      ;
  
  newArrayConstruction