Package: uvlparser
UVL - Universal Variability LanguageThis is a small default library used to parse and print the Universal Variability Language (UVL).Under the hood it usesANTLR4as the parsing library.
The grammar in EBNF form is located inuvl/UVL.g4and the modifications for Java and PythonThe LanguageOn a high level, each feature model in UVL consists of five optional separated elements:A list of used language levelsThe model can use different concepts which are part of language levels. These levels can either be enumerated with theincludekeyword or be implicit.A namespace which can be used for references in other modelsA list of imports that can be used to reference external feature modelsThe models are referenced by their file name and can be given an alias using a Java import like syntax.
External models in subdirectories can be referenced like this: subdir.filename as fnThe tree hierarchy consisting of: features, group types, and attributes whose relations are specified using nesting (indentation)Groups may have an arbitrary number of features as child nodes. A feature can also have a feature cardinality.
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 beconstraint. If the value is a list of constraints the key must beconstraintsCross-tree constraintsCross-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).The following snippet shows a simplified server architecture in UVL. We provide more examples (e.g., to show the composition mechanism) inhttps://github.com/Universal-Variability-Language/uvl-models/tree/main/Feature_Models.namespace Server

features
  Server {abstract}
    mandatory
      FileSystem
        or // with cardinality: [1..*]
          NTFS
          APFS
          EXT4
      OperatingSystem {abstract}
        alternative
          Windows
          macOS
          Debian
    optional
      Logging	{
      default,
      log_level "warn" // Feature Attribute
    }

constraints
  Windows => NTFS
  macOS => APFSIn this snippet, we can recognize the following elements:The featureServeris abstract (i.e., corresponds to no implementation artifact.EachServerrequires aFileSystemand anOperatingSystemdenoted by themandatorygroupTheServermay haveLoggingdenoted by theoptionalgroupAFileSystemrequires at least one type ofNTFS,APFS, andExt4denoted by theorgroupAnOperatingSystemhas exactly one type ofWindows,macOS, andDebiandenoted by thealternativegroupLogginghas the feature attributelog_levelattached which is set to "warn"WindowsrequiresNTFSdenoted by the first cross-tree constraintmacOSrequiresAPFSBuilding a jarThe 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:mvn clean compile assembly:singleThetarget/uvl-parser-1.0-SNAPSHOT-jar-with-dependencies.jarincludes all dependencies.Usage from JavaThe classde.vill.main.UVLModelFactoryexposes the static methodparse(String)which will return an instance of ade.vill.model.FeatureModelclass. If there is something wrong, ade.vill.exception.ParseErroris thrown. The parser tries to parse the whole model, even if there are errors. If there are multiple errors, ade.vill.exception.ParseErrorListis returned which contains all errors that occurred.
A model can be printed with thetoString()method of thede.vill.model.FeatureModelobject.
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 insrc/main/java/de/vill/main/Example.java// ReadPathfilePath=Paths.get(pathAsString);Stringcontent=newString(Files.readAllBytes(filePath));UVLModelFactoryuvlModelFactory=newUVLModelFactory();FeatureModelfeatureModel=uvlModelFactory.parse(content);// WriteStringuvlModel=featureModel.toString();PathfilePath=Paths.get(featureModel.getNamespace()+".uvl");Files.write(filePath,uvlModel.getBytes());LinksUVL models:https://github.com/Universal-Variability-Language/uvl-modelsOther parsers:https://github.com/Universal-Variability-Language/uvl-parserdeprecated, Initial UVL Parser, based on Clojure and instaparseUVL-Parserhttps://github.com/diverso-lab/uvl-diverso/Under development, Antlr4 ParserDiverso LabUsage of UVL:https://github.com/FeatureIDE/FeatureIDEFeature modelling tool