Skip to main content

Parser for Universal Variability Language (UVL) with CNF conversion support

Project description

uvllang

A Python parser for the Universal Variability Language (UVL). Based on ANTLR4, adopted from https://github.com/Universal-Variability-Language/uvl-parser.

Installation

pip install uvllang

Usage

Parsing

from uvllang.main import UVL

# Parse a UVL file
model = UVL(from_file="examples/automotive01.uvl")

# Access features
print(f"Number of features:", len(model.features))

# Access constraints
print("All constraints:", len(model.constraints))
print("Boolean constraints:", len(model.boolean_constraints))
print("Arithmetic constraints:", len(model.arithmetic_constraints))

CNF Conversion

Convert feature models to Conjunctive Normal Form (CNF) for SAT solvers:

from uvllang.main import UVL

# Parse UVL file
model = UVL(from_file="model.uvl")

# Convert to CNF (returns PySAT CNF object)
cnf = model.to_cnf()
cnf.to_file("output.dimacs")

Command Line Interface

uvl2cnf --help

# Basic conversion
uvl2cnf model.uvl

# Specify output file
uvl2cnf model.uvl output.dimacs

# Verbose mode (lists ignored constraints)
uvl2cnf model.uvl -v

Dependencies

  • antlr4-python3-runtime: ANTLR4 parser runtime
  • sympy: Symbolic mathematics for Boolean constraint processing
  • python-sat: SAT solver library for CNF handling

Testing

# Install development dependencies
pip install -e .[dev]

# Run tests
python -m pytest tests/

Development

# Generate parsers from grammar files
python generate_parsers.py

# Build package
python build_package.py

# Or build manually
python -m build

Citation

If you use UVL in your research, please cite:

@article{UVL2024,
  title     = {UVL: Feature modelling with the Universal Variability Language},
  journal   = {Journal of Systems and Software},
  volume    = {225},
  pages     = {112326},
  year      = {2025},
  doi       = {https://doi.org/10.1016/j.jss.2024.112326},
  author    = {David Benavides and Chico Sundermann and Kevin Feichtinger and José A. Galindo and Rick Rabiser and Thomas Thüm}
}

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uvllang-0.1.1.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uvllang-0.1.1-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file uvllang-0.1.1.tar.gz.

File metadata

  • Download URL: uvllang-0.1.1.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for uvllang-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5f3c7a37a90582484d6e6039fcf842d6a4ad247b5b267fb134d7296b59479168
MD5 40cc09413d5065d2bb0e14b2afc8e2be
BLAKE2b-256 4efe3b9c5e7e05d0e0de37cb0283f3172f9663a0a965ce2f72420f63960c073e

See more details on using hashes here.

File details

Details for the file uvllang-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: uvllang-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for uvllang-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca19a6d0e2eade0d77944cd3273a9d264fdeb6c9529f20818fa640aabf68ce2e
MD5 6ede6b14f00f061d667e44511cf88154
BLAKE2b-256 d6c8d74d70f231c26ea081373fa5db481f117a88a8cf669c5b9c2c24abde9062

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page