org.openprovenance.prov.template.emitter.minilanguage.Conditional Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of prov-template-compiler Show documentation
Show all versions of prov-template-compiler Show documentation
A template system for PROV bundles.
The newest version!
package org.openprovenance.prov.template.emitter.minilanguage;
import org.openprovenance.prov.template.emitter.Element;
import org.openprovenance.prov.template.emitter.minilanguage.emitters.Python;
import java.util.List;
public class Conditional extends Statement{
public Expression predicate;
public List consequents;
public List alternates;
public Conditional(List elements) {
super(elements);
}
@Override
public void emit(Python emitter, List classVariables, List listVariables) {
emitter.emitBeginLine("if ");
predicate.emit(emitter, true, classVariables, listVariables);
emitter.emitContinueLine(":");
emitter.emitNewline();
emitter.indent();
if (consequents!=null) {
for (Statement consequent : consequents) {
consequent.emit(emitter, classVariables, listVariables);
}
emitter.emitLine("pass");
}
emitter.unindent();
if (alternates!=null && !alternates.isEmpty()) {
emitter.emitBeginLine("else:");
emitter.emitNewline();
emitter.indent();
for (Statement alternate: alternates) {
alternate.emit(emitter, classVariables, listVariables);
}
emitter.unindent();
}
}
@Override
public String toString() {
return "Conditional{" +
"predicate=" + predicate +
", consequents=" + consequents +
", alternates=" + alternates +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy