Revision 56826c2238425cdb84d8583de9bf580c2aac7866 (click the page title to view the current version)
Clafer Compiler Command Line Arguments
Back to Clafer Tools
The following model describes the command line arguments of the
Clafer compiler, as of Clafer 0.5.7, and the dependencies among them.
clafer --help lists the arguments with their
descriptions.
Some clafers for argument modeling. These types are needed to distinguish arguments and their values from any other clafers used for grouping etc.:
The model
A command line either compiles a model, translates an Ecore model into Clafer, or prints information about the compiler.
Notes on the model:
-m(--mode) can be repeated, e.g.,-m alloy -m choco -m html, and every mode produces its own output file; hence,or mode. Without-m, the mode isalloy.- The modes and their output files for a model
model.cfr:alloy:model.als, Alloy 6. A static model is compiled to plain Alloy, and a temporal model (one with mutable clafers or temporal constraints) to Alloy 6 withvarand the temporal operators.--tl(--trace-len) sets the maximum trace length of a temporal model; the default is 10. A model with decimals, reals orproducthas no Alloy output.json:model.json, the intermediate representation.clafer:model.des.cfr, the explicit model: every name is a unique ID (UID), every cardinality is written out, and every expression is fully resolved. It shows how the compiler understood the model. The model above names this valueexplicitClafer, sinceclaferis a reserved word.html:model.html, the model as an HTML fragment, as the wiki shows it.graph:model.dot, a graph of the model in the DOT language of GraphViz.cvlgraph:model.cvl.dot, a graph of the model in the Common Variability Language (CVL) notation.choco:model.js, the input of the Choco-based tools (chocosolver, ClaferMooVisualizer, ClaferConfigurator).
- The modes
html,graphandcvlgraphkeep the abstract clafers that have no instances, as if-k(--keep-unused) were given. --explicitcompiles an explicit model, as-m claferprints it. It is a shorthand for-f -k -l --ss=none; the model above names itexplicitModel.-v(--validate) checks the outputs of all modes with the tools that read them:alloy6.2.0.jarfor Alloy,chocosolver.jarfor Choco,dotfor graphs, and the compiler itself for the explicit model, which must compile to itself. The jars are looked up in--tooldir, by default the current folder. The compiler exits with 1 when a tool rejects an output.--minint,--maxintand--decimal-digitsapply to the Choco output. Without them, chocosolver uses the range -128..127, and the decimals have as many fractional digits as the model’s decimal literals.--meta-dataalso writesmodel.cfr-map(the fully qualified names, least-partially-qualified names and UIDs) and, in the Alloy and Choco modes,model.cfr-scope(the scopes). In the Clafer mode, it writes the explicit model’s scope file,model.des.cfr-scope.--timeout-analysisstops the compiler after the given number of seconds.--import FILEcompiles the model with the model inFILE, a path or an http/https URL. It can be repeated.--import-root,--public-importsand--import-baserestrict what can be imported, e.g., when the compiler runs on a server. The model above names the argumentimportFile.-e(--ecore2clafer) translates an Ecore model into Clafer withecore2clafer.jarfrom--tooldir; all other arguments are ignored.
Options in the model
A model can give its own arguments in its first line, which starts
with //# OPTIONS, e.g.:
//# OPTIONS --maxint 1000 -m choco
x -> integer = 500
An argument given on the command line takes precedence over the same
argument in the model. The imports of both are kept. In
//# OPTIONS, the file of --import is relative
to the model’s folder or URL.
Examples
Here are a few examples of using the arguments for different kinds of outputs:
- produce Alloy code (the default mode)
Command line: clafer model.cfr.
- produce the Alloy code of a temporal model with traces of up to 20 states
Command line: clafer --tl=20 model.cfr.
- produce the outputs for Alloy, Choco and HTML at once, and validate
the Alloy and Choco outputs with the tools in
tools
Command line:
clafer -m alloy -m choco -m html -v --tooldir=tools model.cfr.
- produce the Choco output for integers up to 100
Command line:
clafer -m choco --maxint=100 model.cfr.
- print the explicit model on the console, to see how the compiler resolved the names
Command line: clafer -m clafer -o model.cfr.
- compile the explicit model
model.des.cfrback, e.g., after editing it
Command line:
clafer --explicit -m choco model.des.cfr.
- produce a complete HTML document, which includes the CSS, the
comments of the model, and a graph in place of the
//# GRAPHdirective
Command line:
clafer -m html --self-contained --add-graph --add-comments model.cfr.
The option --add-graph needs dot on the system
path.
- compile a model with a model it imports
Command line: clafer --import=base.cfr model.cfr.
- translate an Ecore model into Clafer
Command line: clafer -e --tooldir=tools model.ecore.
