Skip to content

Commit bfecb77

Browse files
authored
docs: add explantions about the aggreate functions (#59)
1 parent 602cafe commit bfecb77

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

README.md

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# UVL - Universal Variability Language
2+
23
This is a small default library used to parse and print the Universal Variability Language (UVL).
34

45
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
910
On a high level, each feature model in UVL consists of five optional separated elements:
1011

1112
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.
1314
2. **A namespace which can be used for references in other models**
1415
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
1718
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`
2021
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+
```
2228

2329
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).
2430

@@ -50,28 +56,31 @@ constraints
5056
```
5157

5258
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`
6168

6269
## Building a jar
6370

6471
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+
6573
```
6674
mvn clean compile assembly:single
6775
```
6876

6977
The `target/uvl-parser-1.0-SNAPSHOT-jar-with-dependencies.jar` includes all dependencies.
7078

7179
## Usage from Java
80+
7281
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.
7382
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)
7584

7685
```Java
7786
// Read
@@ -85,17 +94,19 @@ FeatureModel featureModel = uvlModelFactory.parse(content);
8594
String uvlModel = featureModel.toString();
8695
Path filePath = Paths.get(featureModel.getNamespace() + ".uvl");
8796
Files.write(filePath, uvlModel.getBytes());
88-
```
97+
```
8998

9099
## Links
100+
91101
UVL models:
92-
* https://github.com/Universal-Variability-Language/uvl-models
102+
103+
- https://github.com/Universal-Variability-Language/uvl-models
93104

94105
Other parsers:
95-
* https://github.com/Universal-Variability-Language/uvl-parser *deprecated, Initial UVL Parser, based on Clojure and instaparse* **UVL-Parser**
96-
* https://github.com/diverso-lab/uvl-diverso/ *Under development, Antlr4 Parser* **Diverso Lab**
97106

98-
Usage of UVL:
99-
* https://github.com/FeatureIDE/FeatureIDE *Feature modelling tool*
107+
- https://github.com/Universal-Variability-Language/uvl-parser _deprecated, Initial UVL Parser, based on Clojure and instaparse_ **UVL-Parser**
108+
- https://github.com/diverso-lab/uvl-diverso/ _Under development, Antlr4 Parser_ **Diverso Lab**
100109

110+
Usage of UVL:
101111

112+
- https://github.com/FeatureIDE/FeatureIDE _Feature modelling tool_

0 commit comments

Comments
 (0)