You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-21Lines changed: 32 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
# UVL - Universal Variability Language
2
+
2
3
This is a small default library used to parse and print the Universal Variability Language (UVL).
3
4
4
5
Under the hood it uses [ANTLR4](https://www.antlr.org/) as the parsing library.
@@ -9,16 +10,21 @@ The grammar in EBNF form is located in `uvl/UVL.g4` and the modifications for Ja
9
10
On a high level, each feature model in UVL consists of five optional separated elements:
10
11
11
12
1.**A list of used language levels**
12
-
The model can use different concepts which are part of language levels. These levels can either be enumerated with the `include` keyword or be implicit.
13
+
The model can use different concepts which are part of language levels. These levels can either be enumerated with the `include` keyword or be implicit.
13
14
2.**A namespace which can be used for references in other models**
14
15
3.**A list of imports that can be used to reference external feature models**
15
-
The models are referenced by their file name and can be given an alias using a Java import like syntax.
16
-
External models in subdirectories can be referenced like this: subdir.filename as fn
16
+
The models are referenced by their file name and can be given an alias using a Java import like syntax.
17
+
External models in subdirectories can be referenced like this: subdir.filename as fn
17
18
4.**The tree hierarchy consisting of: features, group types, and attributes whose relations are specified using nesting (indentation)**
18
-
Groups may have an arbitrary number of features as child nodes. A feature can also have a feature cardinality.
19
-
Attributes consist of a key-value pair whose key is always a string and its value may be a boolean, number, string, a list attributes, a vector, or a constraint. If the value is a constraint the key must be `constraint`. If the value is a list of constraints the key must be `constraints`
19
+
Groups may have an arbitrary number of features as child nodes. A feature can also have a feature cardinality.
20
+
Attributes consist of a key-value pair whose key is always a string and its value may be a boolean, number, string, a list attributes, a vector, or a constraint. If the value is a constraint the key must be `constraint`. If the value is a list of constraints the key must be `constraints`
20
21
5.**Cross-tree constraints**
21
-
Cross-tree constraints may be arbitrary propositional formulas with the following symbols: => (implies), <=> (iff), & (and), | (or), ! (not), or brackets. Through the usage of language levels cross-tree constraints can also contain equations (<,>,==) which consist of expressions (+,-,*,/) with numbers or numerical feature attributes as literals and aggregate functions (avg, sum).
22
+
Cross-tree constraints may be arbitrary propositional formulas with the following symbols: => (implies), <=> (iff), & (and), | (or), ! (not), or brackets. Through the usage of language levels cross-tree constraints can also contain equations (<,>,==) which consist of expressions (+,-,\*,/) with numbers or numerical feature attributes as literals and aggregate functions (avg, sum).
23
+
The sum and avg functions compute the total or average of a numeric attribute across all instances, optionally limited to a specified feature subtree, using the syntax e.g.
24
+
```
25
+
constraints
26
+
sum(att, rootFeature).
27
+
```
22
28
23
29
The following snippet shows a simplified server architecture in UVL. We provide more examples (e.g., to show the composition mechanism) in [https://github.com/Universal-Variability-Language/uvl-models/tree/main/Feature_Models](https://github.com/Universal-Variability-Language/uvl-models/tree/main/Feature_Models).
24
30
@@ -50,28 +56,31 @@ constraints
50
56
```
51
57
52
58
In this snippet, we can recognize the following elements:
53
-
* The feature `Server` is abstract (i.e., corresponds to no implementation artifact.
54
-
* Each `Server` requires a `FileSystem`and an `OperatingSystem` denoted by the *mandatory* group
55
-
* The `Server` may have `Logging` denoted by the *optional* group
56
-
* A `FileSystem` requires at least one type of `NTFS`, `APFS`, and `Ext4` denoted by the *or* group
57
-
* An `OperatingSystem` has exactly one type of `Windows`, `macOS`, and `Debian`denoted by the *alternative* group
58
-
*`Logging` has the feature attribute `log_level` attached which is set to "warn"
59
-
*`Windows` requires `NTFS` denoted by the first cross-tree constraint
60
-
*`macOS`requires `APFS`
59
+
60
+
- The feature `Server` is abstract (i.e., corresponds to no implementation artifact.
61
+
- Each `Server` requires a `FileSystem`and an `OperatingSystem` denoted by the _mandatory_ group
62
+
- The `Server` may have `Logging` denoted by the _optional_ group
63
+
- A `FileSystem` requires at least one type of `NTFS`, `APFS`, and `Ext4` denoted by the _or_ group
64
+
- An `OperatingSystem` has exactly one type of `Windows`, `macOS`, and `Debian`denoted by the _alternative_ group
65
+
-`Logging` has the feature attribute `log_level` attached which is set to "warn"
66
+
-`Windows` requires `NTFS` denoted by the first cross-tree constraint
67
+
-`macOS`requires `APFS`
61
68
62
69
## Building a jar
63
70
64
71
The library is a maven project and can therefore be build with maven. To update the generated parser classes and create a jar with all necessary dependencies, use:
72
+
65
73
```
66
74
mvn clean compile assembly:single
67
75
```
68
76
69
77
The `target/uvl-parser-1.0-SNAPSHOT-jar-with-dependencies.jar` includes all dependencies.
70
78
71
79
## Usage from Java
80
+
72
81
The class `de.vill.main.UVLModelFactory` exposes the static method `parse(String)` which will return an instance of a `de.vill.model.FeatureModel` class. If there is something wrong, a `de.vill.exception.ParseError` is thrown. The parser tries to parse the whole model, even if there are errors. If there are multiple errors, a `de.vill.exception.ParseErrorList` is returned which contains all errors that occurred.
73
82
A model can be printed with the `toString()` method of the `de.vill.model.FeatureModel` object.
74
-
The following snippet shows a minimal example to read and write UVL models using the jar. More usage examples that also show how to use the acquired UVLModel object can be found in [src/main/java/de/vill/main/Example.java](https://github.com/Universal-Variability-Language/uvl-parser2.0/blob/main/src/main/java/de/vill/main/Example.java)
83
+
The following snippet shows a minimal example to read and write UVL models using the jar. More usage examples that also show how to use the acquired UVLModel object can be found in [src/main/java/de/vill/main/Example.java](https://github.com/Universal-Variability-Language/java-fm-metamodel/blob/main/src/main/java/de/vill/main/Example.java)
0 commit comments