The phases following annotation processing: attribution,
desugar, and finally code generation.
517379
private void compile2() {
        try {
            switch (compilePolicy) {
            case ATTR_ONLY:
                attribute(todo);
                break;

            case CHECK_ONLY:
                flow(attribute(todo));
                break;

            case SIMPLE:
                generate(desugar(flow(attribute(todo))));
                break;

            case BY_FILE: {
                    Queue<Queue<Env<AttrContext>>> q = todo.groupByFile();
                    while (!q.isEmpty() && !shouldStop(CompileState.ATTR)) {
                        generate(desugar(flow(attribute(q.remove()))));
                    }
                }
                break;

            case BY_TODO:
                while (!todo.isEmpty())
                    generate(desugar(flow(attribute(todo.remove()))));
                break;

            default:
                Assert.error("unknown compile policy");
            }
        } catch (Abort ex) {
            if (devVerbose)
                ex.printStackTrace(System.err);
        }

        if (verbose) {
            elapsed_msec = elapsed(start_msec);
            log.printVerbose("total", Long.toString(elapsed_msec));
        }

        reportDeferredDiagnostics();

        if (!log.hasDiagnosticListener()) {
            printCount("error", errorCount());
            printCount("warn", warningCount());
        }
    }
753896
private void processIgnoredLeadingTokens(ParseTreeNode node, int position, int line, MemoEntry progress)
	    throws TreeException, ParserException {
	if (ignoredLeading) {
	    processIgnoredTokens(node, position, line, progress);
	}
    }
753404
function createAnnotation(desc) {
  utils.check(['type', 'hasTarget', 'annotatedBy'], desc);

  var anno = { type: desc.type, hasTarget: desc.hasTarget, annotatedAt : desc.annotatedAt || new Date().toISOString(), annotatedBy : desc.annotatedBy, state: desc.state || utils.states.annotations.unvalidated};

 // used to create a hierarchical position
 // FIXME reconcile roots / position
  var position = desc.roots || [], flattened = desc.type + unitSep;
  anno.roots = desc.roots || [];
  if (desc.type === 'quote') {
    utils.check(['ranges', 'quote'], desc);
    if (!desc.ranges || desc.ranges.length < 1) {
      utils.checkError(desc, 'missing ranges');
    }
    anno.quote = desc.quote;
    anno.ranges = desc.ranges;
    position.push(anno.quote);
    flattened += position.join(unitSep);
  } else if (desc.type === 'category') {
    utils.check(['category'], desc);
    anno.category = Array.isArray(desc.category) ? desc.category : [desc.category];
    position = position.concat(anno.category);
    flattened += position.join(unitSep);
  } else if (desc.type === 'value' || desc.type === 'valueQuote') {
    utils.check(['key', 'value'], desc);
    if (desc.type === 'valueQuote') {
      utils.check(['ranges'], desc);
      anno.ranges = desc.ranges;
    }
    anno.key = desc.key;
    anno.value = desc.value;
    position.push(desc.key);
    flattened += position.join(unitSep) + unitSep + desc.value;

// add data types
    if (desc.isA) {
      try {
        anno.isA = desc.isA;
        anno.typed = {};
        anno.typed[desc.isA] = dataTypes[desc.isA](desc.value);
      } catch (e) {
        anno.typed.failure = e;
        GLOBAL.warn('isA failed', e, desc);
      }
    }
  } else {
    throw new Error('unknown type ' + desc.type);
  }
  anno.position = position;
  anno.flattened = flattened;
  if (anno.attributes) {
    anno.attributes = desc.attributes; // additional attributes
  }
  return anno;
}
422842
function SemanticChecker(tokens) {
    this._tokens = tokens;
    this._index = -1;
    this._tree = null;
    this._stack = [];
    if (!this.checkExp()) {
        throw [0, "This is not a understandable expression!"];
    }
    if (this.tkn() !== null) {
        throw [this._index, "Unexpected end of expression! Maybe you forgot a \"(\" somewhere."];
    }
}
1303829
def _process_refs(x, labels):
    """"""

    # Scan the element list x for Cite elements with known labels
    for i, v in enumerate(x):
        if v['t'] == 'Cite' and len(v['c']) == 2 and \
          _get_label(v['t'], v['c']) in labels:

            # A new reference was found; create some empty attributes for it
            attrs = ['', [], []]

            # Extract the modifiers.  'attrs' is updated in place.  Element
            # deletion could change the index of the Cite being processed.
            if i > 0:
                i = _extract_modifier(x, i, attrs)

            # Attach the attributes
            v['c'].insert(0, attrs)

            # Remove surrounding brackets
            if i > 0 and i < len(x)-1:
                _remove_brackets(x, i)

            # The element list may be changed
            return None  # Forces processing to repeat via _repeat decorator

    return True
730884
function annotate(fn) {
  var matched = /function +[^\(]*\(([^\)]*)\).*/.exec(fn.toString());
  var names = _.reject(matched[1].split(',') || [], _.isEmpty);

  return _.map(names, function(name) {
    return name.replace(/\s+/g, '');
  });
}
1136342
def handle_annotation_pattern(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
        
        annotation = tokens['name']
        self.raise_for_redefined_annotation(line, position, annotation)
        self.annotation_to_pattern[annotation] = re.compile(tokens['value'])
        return tokens
306261
void generateValidationChecks(
            final CtClass ctClass,
            final StringBuilder validationChecksCode,
            final StringBuilder staticInitializerCode,
            final List<String> staticFields) {

        for (final CtField ctField : ctClass.getDeclaredFields()) {
            for (final Object annotationObject : ctField.getAvailableAnnotations()) {
                final Annotation annotation = (Annotation) annotationObject;
                if (ANNOTATIONS.contains(annotation.annotationType())) {
                    final Constraint constraint = annotation.annotationType().getAnnotation(Constraint.class);
                    final Class<? extends AnnotationCheck<? extends Annotation>> checkClass = constraint.checkWith();
                    final String checkType = checkClass.getName();
                    final String checkName = getCheckName(ctField.getName(), checkType);
                    final String fieldName = ctField.getName();

                    // Define the member for the check
                    staticFields.add(generateCheckFieldDeclaration(checkType, checkName));

                    // Define the member for the field context
                    staticFields.add(generateFieldContextDeclaration(ctClass.getName(), checkName, fieldName));

                    // Write the check initializer code
                    staticInitializerCode.append(
                            generateCheckInitializer(
                                    ctClass.getName(),
                                    checkName,
                                    fieldName,
                                    annotation.annotationType().getName()));

                    // Write the validation code
                    validationChecksCode.append(generateValidation(
                            annotation,
                            checkType,
                            checkName,
                            fieldName));
                }
            }
        }
    }
104381
public final void annotationConstantRest() throws RecognitionException {
		VarDecl_stack.push(new VarDecl_scope());

		int annotationConstantRest_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 78) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:673:6: ( variableDeclarators )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:673:8: variableDeclarators
			{
			pushFollow(FOLLOW_variableDeclarators_in_annotationConstantRest2702);
			variableDeclarators();
			state._fsp--;
			if (state.failed) return;
			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 78, annotationConstantRest_StartIndex); }

			VarDecl_stack.pop();

		}
	}
1361571
function(line) {
			// Find any existing annotation
			var annotationModel = this.getAnnotationModel();
			var textModel = this.getModel();
			if (textModel.getBaseModel) {
				textModel = textModel.getBaseModel();
			}
			var type = AT.ANNOTATION_HIGHLIGHTED_LINE;
			var annotations = annotationModel.getAnnotations(0, textModel.getCharCount());
			var remove = null;
			while (annotations.hasNext()) {
				var annotation = annotations.next();
				if (annotation.type === type) {
					remove = annotation;
					break;
				}
			}
			var lineStart = textModel.getLineStart(line);
			var lineEnd = textModel.getLineEnd(line);
			var add = AT.createAnnotation(type, lineStart, lineEnd);
			// Replace to or add the new annotation
			if (remove) {
				annotationModel.replaceAnnotations([remove], [add]);
			} else {
				annotationModel.addAnnotation(add);
			}
		}
656407
def p_annotation(self, p):
        ''''''

        if len(p) == 4:
            p[0] = ast.Annotation(p[1], p[3], lineno=p.lineno(1))
        else:
            p[0] = ast.Annotation(p[1], True, lineno=p.lineno(1))
428195
public static SpanFeatureAnnotation annotate(AnnotatedSentence sentence,
      FeatureVectorGenerator<StringContext> featureGenerator) {
    int numTerminals = sentence.size();
    Tensor[] featureVectors = new Tensor[numTerminals * (numTerminals + 1) / 2];
    for (int i = 0; i < numTerminals; i++) {
      for (int j = i; j < numTerminals; j++) {
        int spanIndex = getSpanIndex(i, j, numTerminals);
        featureVectors[spanIndex] = featureGenerator.apply(
            new StringContext(i, j, sentence));
      }
    }
    return new SpanFeatureAnnotation(featureVectors, numTerminals);
  }
20526
function (){
    this._is_a = 'amigo.linker';

    // Easy app base.
    var sd = amigo_data_server;
    this.app_base = sd.app_base();
    // Internal term matcher.
    this.term_regexp = null;
    var internal_regexp_str = sd.term_regexp();    
    if( internal_regexp_str ){
	this.term_regexp = new RegExp(internal_regexp_str);
    }

    // Categories for different special cases (internal links).
    this.ont_category = {
	'term': true,
	'ontology_class': true,
	'annotation_class': true,
	'annotation_class_closure': true,
	'annotation_class_list': true,
	// Noctua model stuff.
	'function_class': true,
	'function_class_closure': true,
	'process_class': true,
	'process_class_closure': true,
	'location_list': true,
	'location_list_closure': true
    };
    this.bio_category = {
        'gp': true,
	'gene_product': true,
	'bioentity': true
    };
    this.model_category = {
        'model': true
    };
    this.search_category = { // not including the trivial medial_search below
        'search': true,
	'live_search': true
    };
    this.search_modifier = {
	// Possibly "dynamic".
	'gene_product': '/bioentity',
	'bioentity': '/bioentity',
	'ontology': '/ontology',
	'annotation': '/annotation',
	'model': '/model',
	'family': '/family',
	'lego_unit': '/lego_unit',
	'general': '/general'
    };
    this.other_interlinks = {
	'medial_search': '/amigo/medial_search',
	'landing': '/amigo/landing',
	'tools': '/amigo/software_list',
	'schema_details': '/amigo/schema_details',
	'load_details': '/amigo/load_details',
	'browse': '/amigo/browse',
	'goose': '/goose',
	'grebe': '/grebe',
	'gannet': '/gannet',
	'repl': '/repl'	
    };
}
103471
private void processFields() {
    List<Field> children = IntrospectionUtils.getPersistableFields(clazz);
    for (Field child : children) {
      if (child.isAnnotationPresent(Embedded.class)) {
        processEmbeddedField(child);
      } else {
        processSimpleField(child);
      }
    }
  }
410484
private void handleResidueAnnotation(String seqName, String featureName, String value) {

		if (featureName.equals(GR_SURFACE_ACCESSIBILITY)) {
			stockholmStructure.addSurfaceAccessibility(seqName, value);
		} else if (featureName.equals(GR_TRANS_MEMBRANE)) {
			stockholmStructure.addTransMembrane(seqName, value);
		} else if (featureName.equals(GR_POSTERIOR_PROBABILITY)) {
			stockholmStructure.addPosteriorProbability(seqName, value);
		} else if (featureName.equals(GR_LIGAND_BINDING)) {
			stockholmStructure.addLigandBinding(seqName, value);
		} else if (featureName.equals(GR_ACTIVE_SITE)) {
			stockholmStructure.addActiveSite(seqName, value);
		} else if (featureName.equals(GR_AS_PFAM_PREDICTED)) {
			stockholmStructure.addASPFamPredicted(seqName, value);
		} else if (featureName.equals(GR_AS_SWISSPROT)) {
			stockholmStructure.addASSwissProt(seqName, value);
		} else if (featureName.equals(GR_INTRON)) {
			stockholmStructure.addIntron(seqName, value);
		} else if (featureName.equals(GR_SECONDARY_STRUCTURE)) {
			stockholmStructure.addSecondaryStructure(seqName, value);
		} else {
			// unknown feature
			logger.warn("Unknown Residue Feature [{}].\nPlease contact the Biojava team.", featureName);
		}
	}
963183
def add_annotation(self, about, content, motivated_by="oa:describing"):
        # type: (str, List[str], str) -> str
        """"""
        self.self_check()
        curr = self.base_uri + METADATA + "/"
        content = [c.replace(curr, "").replace(self.base_uri, "../")
                   for c in content]
        uri = uuid.uuid4().urn
        ann = {
            "uri": uri,
            "about": about,
            "content": content,
            "oa:motivatedBy": {"@id": motivated_by}
        }
        self.annotations.append(ann)
        return uri
352695
private void processComment() {
        templateReader.nextCharacter(); // Burning comment opening char.
        if (templateReader.startsWith(syntax.getDocumentTypeOpening())) {
            processSchemaComment();
            return;
        } else if (nestedComments) {
            processNestedComment();
            return;
        }
        while (templateReader.hasNextCharacter()) {
            final char commentCharacter = templateReader.nextCharacter();
            if (isCommentClosingMarker(commentCharacter) && templateReader.hasNextCharacter()
                    && templateReader.peekCharacter() == syntax.getTagClosing()) {
                // Character was a comment closing sign and the next tag closed the comment.
                templateReader.nextCharacter(); // Polling tag closing.
                break;
            }
        }
    }