final String name = an.getText();
BELAnnotationDefinition ad = definedAnnotations.get(name);
if (ad != null) {
// read annotation value
final BELAnnotation annotation;
if (qv != null) {
annotation = new BELAnnotation(ad, qv.getText());
} else if (oi != null) {
annotation = new BELAnnotation(ad, oi.getText());
} else {
if (list == null) {
throw new IllegalStateException("Did not understand annotation value, expecting annotation list form.");
}
String listvalues = list.getText();
listvalues = listvalues.substring(1, listvalues.length() - 1);
annotation = new BELAnnotation(ad, Arrays.asList(ParserUtil.parseListRecord(listvalues)));
}
if (activeStatementGroup != null) {
// add to local statement group scope
sgAnnotationContext.put(name, annotation);