Class Frontend
java.lang.Object
org.clafer.cli.Frontend
Reads a
.cfr model that is not an explicit model: with the Java
frontend (ToIr, then ToAst) in this JVM, or, when the Java
frontend cannot take the model, with the Haskell compiler
(clafer -k -m choco), whose .js file is read with Rhino. The compiler is
ClaferExecutable.find(): clafer next to clafersg.jar, as in Clafer
Tools, or on the PATH.
The Haskell compiler reads the model when:
--haskell-frontendis given;- the model has a
[choco| |]escape, which is JavaScript; - the Java frontend reports errors or fails: if the compiler compiles the model, chocosolver solves its output and says that the Java frontend rejected the model; otherwise the Java frontend's errors are the model's.
--import-root, --public-imports and
--import-base (ModelFiles.ImportOptions).
The model's scopes are those of its explicit model's scope file
(Scopes), as the compiler writes them with
-m clafer --meta-data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA model that cannot be read. -
Method Summary
Modifier and TypeMethodDescriptionstatic JavascriptFileread(File file, joptsimple.OptionSet options, PrintStream out) Reads a.cfrmodel.static JavascriptFilereadWithJava(File file, List<String> imports) Reads a.cfrmodel with the Java frontend, without a fallback.static JavascriptFilereadWithJava(File file, List<String> imports, ModelFiles.ImportOptions restrictions) Reads a.cfrmodel with the Java frontend, without a fallback.
-
Method Details
-
readWithJava
public static JavascriptFile readWithJava(File file, List<String> imports) throws Frontend.ModelException Reads a.cfrmodel with the Java frontend, without a fallback.- Parameters:
file- the modelimports- the imports of the command line- Returns:
- the model, with the scopes of its explicit model's scope file
- Throws:
Frontend.ModelException- with the errors of the model, each at its position in its file
-
readWithJava
public static JavascriptFile readWithJava(File file, List<String> imports, ModelFiles.ImportOptions restrictions) throws Frontend.ModelException Reads a.cfrmodel with the Java frontend, without a fallback.- Parameters:
file- the modelimports- the imports of the command linerestrictions- the restrictions of the imports- Returns:
- the model, with the scopes of its explicit model's scope file
- Throws:
Frontend.ModelException- with the errors of the model, each at its position in its file
-
read
public static JavascriptFile read(File file, joptsimple.OptionSet options, PrintStream out) throws Frontend.ModelException, IOException Reads a.cfrmodel.- Parameters:
file- the modeloptions- the command lineout- where the fallback to the Haskell compiler is reported- Returns:
- the model, its scopes, objectives and assertions
- Throws:
Frontend.ModelException- with the errors of the modelIOException
-