use of us.parr.bookish.model.entity.EntityDef in project bookish by parrt.
the class Translator method visitSite.
@Override
public OutputModelObject visitSite(BookishParser.SiteContext ctx) {
String label = null;
EntityDef def = null;
if (ctx.REF() != null) {
label = stripQuotes(ctx.REF().getText());
def = document.getEntity(label);
if (def == null) {
System.err.printf("line %d: Unknown label '%s'\n", ctx.start.getLine(), label);
return null;
}
}
def.model = new Site((SiteDef) def);
return null;
}
use of us.parr.bookish.model.entity.EntityDef in project bookish by parrt.
the class Translator method visitCitation.
@Override
public OutputModelObject visitCitation(BookishParser.CitationContext ctx) {
String label = null;
EntityDef def = null;
if (ctx.REF() != null) {
label = stripQuotes(ctx.REF().getText());
def = document.getEntity(label);
if (def == null) {
System.err.printf("line %d: Unknown label '%s'\n", ctx.start.getLine(), label);
return null;
}
}
def.model = new Citation(def, label, (TextBlock) visit(ctx.t), (TextBlock) visit(ctx.a));
return null;
}
use of us.parr.bookish.model.entity.EntityDef in project bookish by parrt.
the class Translator method visitSection.
@Override
public OutputModelObject visitSection(BookishParser.SectionContext ctx) {
String title = ctx.sec.getText();
title = title.substring(title.indexOf(' ') + 1).trim();
Pair<String, String> results = splitSectionTitle(title);
title = results.a;
String anchor = results.b;
EntityDef def = null;
if (anchor != null) {
def = document.getEntity(anchor);
if (def == null) {
System.err.printf("line %d: Unknown label '%s'\n", ctx.start.getLine(), anchor);
return null;
}
}
List<ContainerWithTitle> subsections = new ArrayList<>();
for (ParseTree el : ctx.subsection()) {
subsections.add((SubSection) visit(el));
}
Join sec = (Join) visitSection_content(ctx.section_content());
return new Section(def, title, anchor, sec.elements, subsections);
}
use of us.parr.bookish.model.entity.EntityDef in project bookish by parrt.
the class Translator method visitSubsubsection.
@Override
public OutputModelObject visitSubsubsection(BookishParser.SubsubsectionContext ctx) {
String title = ctx.sec.getText();
title = title.substring(title.indexOf(' ') + 1).trim();
Pair<String, String> results = splitSectionTitle(title);
title = results.a;
String anchor = results.b;
EntityDef def = null;
if (anchor != null) {
def = document.getEntity(anchor);
if (def == null) {
System.err.printf("line %d: Unknown label '%s'\n", ctx.start.getLine(), anchor);
}
}
Join sec = (Join) visitSection_content(ctx.section_content());
return new SubSubSection(def, title, anchor, sec != null ? sec.elements : null);
}
use of us.parr.bookish.model.entity.EntityDef in project bookish by parrt.
the class Translator method lookupEntity.
public EntityDef lookupEntity(TerminalNode refNode) {
EntityDef def = null;
if (refNode != null) {
String label = stripQuotes(refNode.getText());
def = document.getEntity(label);
if (def == null) {
System.err.printf("line %d: Unknown label '%s'\n", refNode.getSymbol().getLine(), label);
}
}
return def;
}
Aggregations