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:     options {memoize=true;}
      : compilerAnnotations
        ( 
          (annotatedDeclarationStart) => d=declaration
          { $statement=$d.declaration; }
        | (annotatedAssertionStart) => assertion
          { $statement = $assertion.assertion; }
        | (annotationListStart) => d1=declaration
          { $statement=$d1.declaration; }
        | s=statement
          { $statement=$s.statement; }
        )
  
negative.code:             ImportList importList = new ImportList(null); 
              $compilationUnit.setImportList(importList); }
      : ( 
          ca=compilerAnnotations
          SEMICOLON
          { $compilationUnit.getCompilerAnnotations().addAll($ca.annotations); }
        )?
        ( 
          importDeclaration 
          { importList.addImport($importDeclaration.importDeclaration); 
            $compilationUnit.connect(importList); }
        |
          (annotatedModuleDescriptorStart) =>
          moduleDescriptor 
          { $compilationUnit.addModuleDescriptor($moduleDescriptor.moduleDescriptor); }
        |
          (annotatedPackageDescriptorStart) =>
          packageDescriptor
          { $compilationUnit.addPackageDescriptor($packageDescriptor.packageDescriptor); }
        |
          toplevelDeclaration
          { if ($toplevelDeclaration.declaration!=null)
                $compilationUnit.addDeclaration($toplevelDeclaration.declaration); }
        | RBRACE
          { displayRecognitionError(getTokenNames(),
                new MismatchedTokenException(EOF, input)); }
        )*
        EOF
      ;
  
  toplevelDeclaration returns [Declaration declaration]
      : ca=compilerAnnotations 
        d=declaration
        { $declaration = $d.declaration;
          if ($declaration!=null)
              $declaration.getCompilerAnnotations().addAll($ca.annotations); }
      ;
  
  annotatedModuleDescriptorStart
      : compilerAnnotations annotations MODULE
      ;
  
  annotatedPackageDescriptorStart
      : compilerAnnotations annotations PACKAGE
      ;
  
  moduleDescriptor returns [ModuleDescriptor moduleDescriptor]
  