Metadata-Version: 2.4
Name: bgd-dsl
Version: 0.1.0
Summary: Parser for BGD DSL Protocol embedded in text descriptions
Author: Artem Ganeev
License: MIT
Keywords: dsl,parser,bgd,text-parser
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# BGD DSL Parser

---

## Quick Start

```python
from bgd_dsl import parse

text = get_some_data()
data: Dict = parse(text)

print(data)
```

Parser for **BGD DSL Protocol** — a lightweight embedded DSL used to store structured product data inside plain text descriptions.

The library extracts a DSL block from text and converts it into a structured Python dictionary.

---

## Features

- Parse structured data from text descriptions
- Versioned DSL support
- Nested fields (`a.b.c`)
- Automatic type parsing
- Lists support
- Comment support
- Easy integration via pip / poetry

---

## Installation

### pip

```bash
pip install bgd-dsl
```

### poetry

```bash
poetry add bgd-dsl
```

---

## Quick Start

### parse file

```python
from bgd_dsl import parse

text = open("src/description.txt").read()
data = parse(text)

print(data)
```

### Output

```json
{
    "metadata": {
        "version": 1,
        "updated_by": "wb_sync_service",
        "updated_at": "2026-02-24T00:00:00"
    },
    "core": {
        "weight_kg": 1.25,
        "length_cm": 80,
        "width_cm": 50,
        "height_cm": 10,
        "material": "polyester",
        "season": "winter",
        "dimensions": {
            "width_cm": 50,
            "height_cm": 80,
            "depth_cm": 10
        },
        "sizes": ["M", "L", "XXL"]
    },
    "override": {
        "wb": {
            "package_type": "BOX"
        },
        "ozon": {
            "age_limit": "adult",
            "sizes": ["S", "M", "L"]
        }
    }
}
```

## BGD DSL Rules

### Sections

Sections define top-level objects:
```bash
[core]
weight_kg = 1.25
```
↓
```json
{
  "core": {
    "weight_kg": 1.25
  }
}
```

### Nested fields

Dot notation creates nested dictionaries:

```bash
dimensions.width_cm = 50
```
↓
```json
{
  "dimensions": {
    "width_cm": 50
  }
}
```

### Lists

Comma-separated values become lists:
```bash
sizes = M, L, XXL
```
↓
```json
["M", "L", "XXL"]
```

### Supported value types

The parser automatically detects:
 - int
 - float
 - bool
 - date (ISO)
 - list
 - dict
 - string

### Comments

Supported comment styles:

```bash
; comment

\\ comment
```

### Versioning

DSL contains a required version:
```bash
[metadata]
version = 1
```

Parser automatically selects the correct implementation.

Future DSL versions are supported without breaking existing integrations.
