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 runtimesympy: Symbolic mathematics for Boolean constraint processingpython-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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uvllang-0.1.2.tar.gz.
File metadata
- Download URL: uvllang-0.1.2.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8691e061e10bbee07b379e85d80930c8c20a46a9215d4abfc22b6557967235a1
|
|
| MD5 |
488d34eba34a2b3ad684665c65539955
|
|
| BLAKE2b-256 |
c3f329fbdb101a39c4a67a013756fcadd603f4f5cb29fd3d26308515e2bbbfbd
|
File details
Details for the file uvllang-0.1.2-py3-none-any.whl.
File metadata
- Download URL: uvllang-0.1.2-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73a6f9e8127a6e85469a49a78f60033e01e2cfd7dc2d079655b757362336923f
|
|
| MD5 |
18e02db4ebfbc04eedb16c8e8aacf5ac
|
|
| BLAKE2b-256 |
3fa6cca4a92df4ce0dfe5e2ea7df5ee327bf97b19c99e38b4635a07e329e4c27
|