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 .

# 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.0.tar.gz (33.3 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.0-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uvllang-0.1.0.tar.gz
  • Upload date:
  • Size: 33.3 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.0.tar.gz
Algorithm Hash digest
SHA256 3371fe0a53c291e1e0258acfa10ce5ec4f7d2ef9e9e5fd4c480c5b571b9f223f
MD5 74f20e930ff974439a390544123ea971
BLAKE2b-256 3f4ff0290a21ab79d390ee5651ed274c794964f44e9367fa04417fd29d4b608f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: uvllang-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee7c20c4ffaea142bc722b07f00253bc10f5da8aff55de7569c32d96ba2f2474
MD5 17947046f26cda405e210079a1d2d95e
BLAKE2b-256 48fd34f86175e7da7f74da31518c3d2b619e78570401f015c0045b5d40bc9990

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