Metadata-Version: 2.4
Name: uvllang
Version: 0.1.2
Summary: Parser for Universal Variability Language (UVL) with CNF conversion support
Author-email: h3ssto <tobias.hess@variability.dev>, UVL Team <jagalindo@us.es>
License-Expression: LGPL-3.0-or-later
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.0
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: antlr4-python3-runtime==4.13.1
Requires-Dist: sympy>=1.12
Requires-Dist: python-sat>=0.1.8.dev13
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: antlr4-tools>=0.2.0; extra == "dev"
Dynamic: license-file

# uvllang

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

## Installation

```bash
pip install uvllang
```

## Usage

### Parsing

```python
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:

```python
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

```bash
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

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

# Run tests
python -m pytest tests/
```

## Development

```bash
# 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:

```bibtex
@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

- [UVL Models Repository](https://github.com/Universal-Variability-Language/uvl-models)
- [UVL Website](https://universal-variability-language.github.io/)
