clafer: clafer compiles Clafer models to other formats, such as Alloy, XML, HTML, Dot.

[ library, mit, model, program ] [ Propose Tags ] [ Report a vulnerability ]
This version is deprecated.

Clafer is a general purpose, lightweight, structural modeling language developed at GSD Lab, University of Waterloo. Lightweight modeling aims at improving the understanding of the problem domain in the early stages of software development and determining the requirements with fewer defects. Clafer's goal is to make modeling more accessible to a wider range of users and domains. The tool provides a reference language implementation. It translates models to other formats (e.g. Alloy, XML) to allow for reasoning with existing tools.


[Skip to Readme]

Modules

[Last Documentation]

  • Language
    • Language.Clafer
      • Language.Clafer.ClaferArgs
      • Language.Clafer.Comments
      • Language.Clafer.Common
      • Language.Clafer.Css
      • Front
        • Language.Clafer.Front.Absclafer
        • Language.Clafer.Front.ErrM
        • Language.Clafer.Front.LayoutResolver
        • Language.Clafer.Front.Lexclafer
        • Language.Clafer.Front.Mapper
        • Language.Clafer.Front.Parclafer
        • Language.Clafer.Front.Printclafer
      • Generator
        • Language.Clafer.Generator.Alloy
        • Language.Clafer.Generator.Choco
        • Language.Clafer.Generator.Graph
        • Language.Clafer.Generator.Html
        • Language.Clafer.Generator.Python
        • Language.Clafer.Generator.Schema
        • Language.Clafer.Generator.Stats
        • Language.Clafer.Generator.Xml
      • Intermediate
        • Language.Clafer.Intermediate.Analysis
        • Language.Clafer.Intermediate.Desugarer
        • Language.Clafer.Intermediate.GLPKScopeAnalyzer
        • Language.Clafer.Intermediate.Intclafer
        • Language.Clafer.Intermediate.Resolver
        • Language.Clafer.Intermediate.ResolverInheritance
        • Language.Clafer.Intermediate.ResolverName
        • Language.Clafer.Intermediate.ResolverType
        • Language.Clafer.Intermediate.ScopeAnalysis
        • Language.Clafer.Intermediate.SimpleScopeAnalyzer
        • Language.Clafer.Intermediate.StringAnalyzer
        • Language.Clafer.Intermediate.Tracing
        • Language.Clafer.Intermediate.Transformer
      • Language.Clafer.JSONMetaData
      • Optimizer
        • Language.Clafer.Optimizer.Optimizer
      • Language.Clafer.QNameUID
      • Language.Clafer.SplitJoin
    • Language.ClaferT

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.3.5, 0.3.5.1, 0.3.6, 0.3.6.1, 0.3.7, 0.3.8, 0.3.9, 0.3.10, 0.4.0, 0.4.1, 0.4.2, 0.4.2.1, 0.4.3, 0.4.4, 0.4.5 (info)
Change log CHANGES.md
Dependencies aeson (>=0.7.0.2), array (>=0.4.0.1), base (>=4.6.0.1 && <5), clafer (==0.3.6), cmdargs (>=0.10.7), containers (>=0.5.0.0), data-stringmap (>=1.0.1.1), directory (>=1.2.0.1), executable-path (>=0.0.3), filepath (>=1.3.0.1), glpk-hs (>=0.3.4), HaXml (==1.24), HUnit (>=1.2.5.2), json-builder (>=0.3), lens (>=4.1.1), MaybeT (>=0.1.2), mtl (>=2.1.2), parsec (>=3.1.3), process (>=1.1.0.2), QuickCheck (>=2.6), split (>=0.2.2), string-conversions (>=0.3.0.2), test-framework (>=0.8.0.3), test-framework-hunit (>=0.3.0.1), test-framework-quickcheck2 (>=0.3.0.2), test-framework-th (>=0.2.4), text (>=0.11.3.1), transformers (>=0.3.0.0) [details]
License MIT
Author Kacper Bąk, Jimmy Liang, Michał Antkiewicz, Chris Walker, Luke Michael Brown
Maintainer Michał Antkiewicz <mantkiew@gsd.uwaterloo.ca>
Category Model
Home page http://clafer.org
Source repo head: git clone git://github.com/gsdlab/clafer.git
Uploaded by mantkiew at 2014-05-23T20:31:57Z
Distributions
Reverse Dependencies 3 direct, 0 indirect [details]
Executables clafer
Downloads 11204 total (28 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-12-15 [all 7 reports]

Readme for clafer-0.3.6

[back to package description]

Clafer

v0.3.6

Clafer is a general-purpose lightweight structural modeling language developed by GSD Lab, University of Waterloo, and MODELS group at IT University of Copenhagen. Clafer can be used for modeling of static hierarchical structures but has no support for modeling the change of the structures over time (behavior). The main goal of Clafer is to make modeling more accessible to a wider range of users and domains.

There are many possible applications of Clafer; however, three are prominent:

  1. Product-Line Modeling - aims at representing and managing commonality and variability of assets in product lines and creating and verifying product configurations. Clafer naturally supports multi-staged configuration.

  2. Multi-Objective Product Optimization - aims at finding a set of products in a given product line that are optimal with respect to a set of objectives. Clafer multi-objective optimizer generates a Pareto front of optimal product configurations.

  3. Domain Modeling - aims at improving the understanding of the problem domain in the early stages of software development and determining the requirements with fewer defects. This is also known as Concept Modeling or Ontology Modeling.

Clafer Compiler

Clafer compiler provides a reference language implementation. It translates models in Clafer to other formats (e.g. Alloy, XML, Python, JS, HTML, DOT) to allow for reasoning and processing with existing tools (Alloy Analyzer, Choco3, and Z3 SMT solver).

Currently, the compiler is used by

Contributors

Getting the Clafer Compiler

Clafer can be installed from a binary distribution (preferred), from Hackage, and from the source code.

Dependencies for running

Regardless of the installation method, the following are

Required:

Optional:

Installation of GLPK

On Linux

  1. libglpk-dev v4.52
  • execute sudo apt-get install libglpk-dev on Ubuntu
  1. libgmp-dev
  • execute sudo apt-get install libgmp-dev on Ubuntu

On Windows

  1. The binary distribution already includes the GNU Linear Programming Kit DLL glpk_4_52.dll.
  2. Install WinGLPK v4.52
  • inside the w32 folder, copy glpk_4_52.dll to glpk.dll so that it can be found when building Haskell package glpk-hs
  • from w32 folder, copy glpk_4_52.dll to <user>\AppData\Roaming\cabal\bin

On Mac

  1. install GPLK 4.52 from MacPorts
  • execute sudo port install glpk +universal

Installation from binaries

Binary distributions of the release 0.3.6 of Clafer Tools for Windows, Mac, and Linux, can be downloaded from Clafer Tools - Binary Distributions.

  1. download the binaries and unpack <target directory> of your choice
  2. add the <target directory> to your system path so that the executables can be found

Installation from Hackage

Dependencies

Clafer is now available on Hackage and it can be installed using

  1. cabal update
  2. cabal install clafer
  3. cd <cabal's lib or share folder> (C:\Users\<user>\AppData\Roaming\cabal\i386-windows-ghc-7.6.3\clafer-0.3.6 on Windows or .cabal/share/x86_64-linux-ghc-7.6.3/clafer-0.3.6/ on Linux)
  4. to automatically download Alloy jars
  • execute make in tools

On Windows

  • copy GLPK's dll glpk-0.4.52.dll to the C:\Users\<user>\AppData\Roaming\cabal\bin folder or any other folder on the system PATH

Installation from the source code

Dependencies

On Windows

  • MinGW+MSYS
    • download mingw-get-setup.exe
    • since the Haskell Platform already contains MinGW, only install MSYS. Installing another MinGW causes problems as it contains different versions of tools as compared to the MinGW in the Haskell Platform
    • choose the existing MinGW location, e.g., c:\...\HaskellPlatform\2013.2.0.0\MinGw
    • ensure wget and unzip are selected to be installed
    • add the bin folder of MSYS (MinGW\MSYS\1.0\bin) to your system path

Important: Branches must correspond

All related projects are following the simultaneous release model. The branch master contains releases, whereas the branch develop contains code under development. When building the tools, the branches should match. Releases from branches 'masterare guaranteed to work well together. Development versions from branchesdevelop` should work well together but this might not always be the case.

Building

  1. install the dependencies
  2. open the command line terminal. On Windows, open MinGW.
  3. in some <source directory> of your choice, execute
  • git clone git://github.com/gsdlab/clafer.git
  1. in <source directory>/clafer, execute
  • cabal update
  1. On Linux and Mac execute
  • make init
  • make
  1. On Windows (in MinGW), execute
  • make glpk=/c/<your WinGLPK install dir>

Installation

  1. On Linux and Mac execute
  • make install to=<target directory>
  1. On Windows (in MinGW), execute
  • make glpk=/c/<your WinGLPK instal dir> to=/c/Users/<your user name>/AppData/Roaming/cabal/bin

Note:

On Windows, use / with the make command instead of \.

Integration with Sublime Text 2

See IDEs/clafer-README.md

Usage

Clafer Compiler

(As printed by clafer --help)

Clafer 0.3.6

clafer [OPTIONS] [FILE]

Common flags:
  -m --mode=CLAFERMODE                    Generated output type. Available
                                          CLAFERMODEs are: 'alloy' (default,
                                          Alloy 4.1); 'alloy42' (Alloy 4.2);
                                          'xml' (intermediate representation of
                                          Clafer model); 'clafer' (analyzed and
                                          desugared clafer model); 'html'
                                          (original model in HTML); 'graph'
                                          (graphical representation written in
                                          DOT language); 'cvlgraph' (cvl
                                          notation representation written in
                                          DOT language); 'python' (generates IR
                                          in python); 'choco' (Choco constraint
                                          programming solver). Multiple modes
                                          can be specified at the same time,
                                          e.g., '-m alloy -m html'.
  -o --console-output                     Output code on console.
  -i --flatten-inheritance                Flatten inheritance ('alloy' and
                                          'alloy42' modes only).
     --timeout-analysis=INT               Timeout for analysis.
  -l --no-layout                          Don't resolve off-side rule layout.
     --nl --new-layout                    Use new fast layout resolver
                                          (experimental).
  -c --check-duplicates                   Check duplicated clafer names in
                                          the entire model.
  -f --skip-resolver                      Skip name resolution.
  -k --keep-unused                        Keep uninstantated abstract clafers
                                          ('alloy' and 'alloy42' modes only).
  -s --no-stats                           Don't print statistics.
     --schema                             Show Clafer IR (intermediate
                                          representation) XML schema.
  -v --validate                           Validate outputs of all modes. Uses
                                          'tools/XsdCheck.class' for XML,
                                          'tools/alloy4.jar' and
                                          'tools/alloy4.2.jar' for Alloy
                                          models, and Clafer translator for
                                          desugared Clafer models. Use
                                          '--tooldir' to override the default
                                          location of these tools.
     --nr --noalloyruncommand             For usage with partial instances:
                                          Don't generate the alloy 'run show
                                          for ... ' command, and rename @.ref
                                          with unique names  ('alloy' and
                                          'alloy42' modes only).
     --tooldir=DIR                        Specify the tools directory
                                          ('validate' only). Default: 'tools/'.
  -a --alloy-mapping                      Generate mapping to Alloy source
                                          code ('alloy' and 'alloy42' modes
                                          only).
     --self-contained                     Generate a self-contained html
                                          document ('html' mode only).
     --add-graph                          Add a graph to the generated html
                                          model ('html' mode only). Requires
                                          the "dot" executable to be on the
                                          system path.
     --sr --show-references               Whether the links for references
                                          should be rendered. ('html' and
                                          'graph' modes only).
     --add-comments                       Include comments from the source
                                          file in the html output ('html' mode
                                          only).
  -e --ecore2clafer                       Translate an ECore model into
                                          Clafer.
     --ss=SCOPESTRATEGY --scope-strategy  Use scope computation strategy:
                                          none, simple (default), or full.
     --check-afm --afm                    Throws an error if the cardinality
                                          of any of the clafers is above 1.
     --sg --skip-goals                    Skip generation of Alloy code for
                                          goals. Useful for all tools working
                                          with standard Alloy.
     --meta-data                          Generate a 'fully qualified
                                          name'-'least-partially-qualified
                                          name'-'unique ID' map ('.cfr-map').
                                          In Alloy, Alloy42, and Choco modes,
                                          generate the scopes map
                                          ('.cfr-scope').
  -? --help                               Display help message
  -V --version                            Print version information

The dependencies among the command line arguments are described on the model wiki.

Multiple modes can be used at the same time. For example,

clafer model.cfr -m alloy -m xml -m html -m graph --self-contained --show-references --no-stats

The mode -m alloy is only a default mode if no other modes are given. When other modes are given, the mode -m alloy must be added explicitly if needed.

Additionally, [OPTIONS] can also be specified directly in the model file by inserting the following compiler directive as the first line of the file:

//# [OPTIONS]

for example

//# --keep-unused -m=alloy42

Options given at command line override the options given in the file using //# which, in turn, override the defaults.

Using compiler directives

Compiler directives are comments of the form

//# <directive name>

The following directives are markers of locations in the input files for different purposes:

  • //# FRAGMENT - marks the beginning of the new module fragment.
  • //# GRAPH - marks the insertion point for a graph rendering. The graph is only produced in HTML mode with the argument --add-graph.
  • //# STATS - marks the insertion point for module statistics. The statistics can be omitted using the argument --no-stats.
  • //# SUMMARY - shorthand for //# GRAPH and //# STATS
  • //# QUALITY_ATTRIBUTE - is used by ClaferMooVisualizer and ClaferConfigurator to distinguish quality attributes, which should be filtered out, from other clafers.

Need help?