use of us.parr.bookish.model.ref.UnknownRef in project bookish by parrt.
the class Translator method visitRef.
@Override
public OutputModelObject visitRef(BookishParser.RefContext ctx) {
String label = stripQuotes(ctx.REF().getText());
EntityDef def = document.getEntity(label);
System.out.println("Ref to " + def);
if (def == null) {
System.err.printf("line %d: Unknown label '%s'\n", ctx.start.getLine(), label);
return new UnknownRef(ctx.REF().getSymbol());
}
Class<? extends EntityRef> refClass = defToRefMap.get(def.getClass());
try {
Constructor<? extends EntityRef> ctor = refClass.getConstructor(EntityDef.class);
EntityRef entityRef = ctor.newInstance(def);
return entityRef;
} catch (Exception e) {
e.printStackTrace(System.err);
}
return null;
}
Aggregations