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.:

abstract Argument
abstract IntegerArgument -> integer
abstract StringArgument -> string
abstract Value
abstract DefaultValue

The model

A command line either compiles a model, translates an Ecore model into Clafer, or prints information about the compiler.

abstract xor ClaferArgs
compile
or mode : Argument
alloy : DefaultValue
alloy_mapping : Argument ?
flatten_inheritance : Argument ?
trace_len : IntegerArgument ?
json : Value
explicitClafer : Value
html : Value
self_contained : Argument ?
add_graph : Argument ?
add_comments : Argument ?
show_references : Argument ?
graph : Value
show_references : Argument ?
cvlgraph : Value
choco : Value
minint : IntegerArgument ?
maxint : IntegerArgument ?
decimal_digits : IntegerArgument ?
console_output : Argument ?
timeout_analysis : IntegerArgument ?
mux layout
no_layout : Argument
new_layout : Argument
check_duplicates : Argument ?
skip_resolver : Argument ?
keep_unused : Argument ?
no_stats : Argument ?
validate : Argument ?
tooldir : StringArgument ?
xor scope_strategy : Argument
none : Value
simple : DefaultValue
check_afm : Argument ?
meta_data : Argument ?
imports
importFile : StringArgument *
import_root : StringArgument *
public_imports : Argument ?
import_base : StringArgument ?
ecore2clafer : Argument
ecoreTooldir : StringArgument ?
help : Argument
version : Argument
numeric_version : Argument

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 is alloy.
  • 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 with var and the temporal operators. --tl (--trace-len) sets the maximum trace length of a temporal model; the default is 10. A model with decimals, reals or product has 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 value explicitClafer, since clafer is 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, graph and cvlgraph keep the abstract clafers that have no instances, as if -k (--keep-unused) were given.
  • --explicit compiles an explicit model, as -m clafer prints it. It is a shorthand for -f -k -l --ss=none; the model above names it explicitModel.
  • -v (--validate) checks the outputs of all modes with the tools that read them: alloy6.2.0.jar for Alloy, chocosolver.jar for Choco, dot for 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, --maxint and --decimal-digits apply 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-data also writes model.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-analysis stops the compiler after the given number of seconds.
  • --import FILE compiles the model with the model in FILE, a path or an http/https URL. It can be repeated. --import-root, --public-imports and --import-base restrict what can be imported, e.g., when the compiler runs on a server. The model above names the argument importFile.
  • -e (--ecore2clafer) translates an Ecore model into Clafer with ecore2clafer.jar from --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:

  1. produce Alloy code (the default mode)
ca1 : ClaferArgs
[ alloy ]
[ simple ]

Command line: clafer model.cfr.

  1. produce the Alloy code of a temporal model with traces of up to 20 states
ca2 : ClaferArgs
[ alloy ]
[ trace_len = 20 ]
[ simple ]

Command line: clafer --tl=20 model.cfr.

  1. produce the outputs for Alloy, Choco and HTML at once, and validate the Alloy and Choco outputs with the tools in tools
ca3 : ClaferArgs
[ alloy && choco && html ]
[ tooldir = "tools" ]
[ simple ]

Command line: clafer -m alloy -m choco -m html -v --tooldir=tools model.cfr.

  1. produce the Choco output for integers up to 100
ca4 : ClaferArgs
[ choco ]
[ no alloy ]
[ maxint = 100 ]
[ simple ]

Command line: clafer -m choco --maxint=100 model.cfr.

  1. print the explicit model on the console, to see how the compiler resolved the names

Command line: clafer -m clafer -o model.cfr.

  1. compile the explicit model model.des.cfr back, e.g., after editing it
ca6 : ClaferArgs
[ choco ]
[ no alloy ]

Command line: clafer --explicit -m choco model.des.cfr.

  1. produce a complete HTML document, which includes the CSS, the comments of the model, and a graph in place of the //# GRAPH directive
ca7 : ClaferArgs
[ html ]
[ no alloy ]
[ simple ]

Command line: clafer -m html --self-contained --add-graph --add-comments model.cfr. The option --add-graph needs dot on the system path.

  1. compile a model with a model it imports
ca8 : ClaferArgs
[ alloy ]
[ one importFile ]
[ some f : importFile | f = "base.cfr" ]
[ simple ]

Command line: clafer --import=base.cfr model.cfr.

  1. translate an Ecore model into Clafer

Command line: clafer -e --tooldir=tools model.ecore.

Module Statistics: | All clafers: 62 | Abstract: 6 | Concrete: 56 | Reference: 2 | Constraints: 35 | Goals: 0 | Global scope: 1..* | Can skip name resolver: no |

Module Downloads: | [.cfr] | [.html] |