anchor.diff:        SEMICOLON
         { $declaration=new BrokenDeclaration($SEMICOLON); }*/
       )
  -    { if ($declaration instanceof com.redhat.ceylon.compiler.typechecker.tree.Tree.Declaration) {
  -          com.redhat.ceylon.compiler.typechecker.tree.Tree.Declaration dec =
  -              (com.redhat.ceylon.compiler.typechecker.tree.Tree.Declaration) $declaration;
  -          dec.setAnnotationList($annotations.annotationList); } }
  +    { if ($declaration!=null)
  +          $declaration.setAnnotationList($annotations.annotationList); }
       ;
   
   annotatedDeclarationStart
  
positive.code:             ImportList importList = new ImportList(null); 
              $compilationUnit.setImportList(importList); }
      : ( 
          ca1=compilerAnnotations
          SEMICOLON
          { $compilationUnit.getCompilerAnnotations().addAll($ca1.annotations); }
        )?
        ( 
          importDeclaration 
          { importList.addImport($importDeclaration.importDeclaration); 
            $compilationUnit.connect(importList); }
        |
          (compilerAnnotations annotations MODULE)=>
          moduleDescriptor 
          { $compilationUnit.addModuleDescriptor($moduleDescriptor.moduleDescriptor); }
        |
          (compilerAnnotations annotations PACKAGE)=>
          packageDescriptor
          { $compilationUnit.addPackageDescriptor($packageDescriptor.packageDescriptor); }
        |
          ca2=compilerAnnotations declaration
          { if ($declaration.declaration instanceof 
                    com.redhat.ceylon.compiler.typechecker.tree.Tree.Declaration) {
                com.redhat.ceylon.compiler.typechecker.tree.Tree.Declaration dec = 
                    (com.redhat.ceylon.compiler.typechecker.tree.Tree.Declaration) 
                        $declaration.declaration;
                $compilationUnit.addDeclaration(dec); 
                $declaration.declaration.getCompilerAnnotations().addAll($ca2.annotations); } }
        | RBRACE
          { displayRecognitionError(getTokenNames(),
                new MismatchedTokenException(EOF, input)); }
        )*
        EOF
      ;
  
  moduleDescriptor returns [ModuleDescriptor moduleDescriptor]
  
negative.code:             $statement.getCompilerAnnotations().addAll($compilerAnnotations.annotations); }
      ;
  
  declaration returns [Declaration declaration]
      @init { MissingDeclaration md = new MissingDeclaration(null); 
              $declaration = md; }
      : annotations
  