Metadata-Version: 2.4
Name: cobol-parser
Version: 1.7.7
Summary: A comprehensive COBOL parser for Python with IBM Enterprise COBOL focus
Author: Samuel Dion
License: END-USER LICENSE AGREEMENT (EULA)
        
        Copyright (c) 2026 Samuel Dion. All rights reserved.
        
        PLEASE READ THIS END-USER LICENSE AGREEMENT ("AGREEMENT") CAREFULLY BEFORE
        USING THIS SOFTWARE. BY USING, COPYING, OR DISTRIBUTING THIS SOFTWARE, YOU
        AGREE TO BE BOUND BY THE TERMS OF THIS AGREEMENT.
        
        1. GRANT OF LICENSE
        
           Subject to the terms and conditions of this Agreement, Samuel Dion ("Licensor")
           grants you a non-exclusive, non-transferable, royalty-free license to:
        
           a) Use this software for personal, educational, or internal business purposes;
           b) Copy and modify the software solely for your own use; and
           c) Share the software with others, provided that such sharing is done free of
              charge and this Agreement is included in its entirety.
        
        2. RESTRICTIONS
        
           You may NOT:
        
           a) Sell, sublicense, rent, lease, or otherwise transfer the software or any
              derivative work based upon the software in exchange for any fee, payment,
              or other compensation of any kind;
           b) Include this software, in whole or in part, in any product or service that
              is sold or offered for sale; or
           c) Remove or alter any copyright notices or this Agreement from any copy of
              the software.
        
        3. OWNERSHIP
        
           This software and all copies thereof are proprietary to Samuel Dion and title
           thereto remains with Samuel Dion. All rights in the software not specifically
           granted in this Agreement are reserved to Samuel Dion.
        
        4. DISCLAIMER OF WARRANTIES
        
           THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
           IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
           FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. IN NO EVENT SHALL
           SAMUEL DION BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM,
           OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
           THE SOFTWARE.
        
        5. TERMINATION
        
           This Agreement is effective until terminated. Your rights under this Agreement
           will terminate automatically without notice if you fail to comply with any of
           its terms. Upon termination, you must destroy all copies of the software in
           your possession.
        
        6. GOVERNING LAW
        
           This Agreement shall be governed by and construed in accordance with applicable
           law, without regard to conflicts of law principles.
        
        ---
        For permissions beyond the scope of this license, contact: Samuel Dion
        
Project-URL: Homepage, https://github.com/Landparty/cobol-parser
Project-URL: Repository, https://github.com/Landparty/cobol-parser
Project-URL: Bug Tracker, https://github.com/Landparty/cobol-parser/issues
Keywords: cobol,parser,mainframe,ibm,enterprise,legacy
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Compilers
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: fast
Requires-Dist: cython>=3.0; extra == "fast"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: pytest-xdist>=3.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: mypy>=1.5.0; extra == "dev"
Requires-Dist: cython>=3.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=7.0.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
Provides-Extra: profiling
Requires-Dist: psutil>=5.9; extra == "profiling"
Dynamic: license-file

# cobol-parser

Python library for parsing IBM Enterprise COBOL source into an AST. Supports dependency extraction, dead code detection, program flow analysis, and CRUD matrices. 99.1% parse success on the NIST COBOL-85 corpus.

[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
[![Tests](https://img.shields.io/badge/tests-8000%2B%20passing-green.svg)](#commands)
[![Coverage](https://img.shields.io/badge/coverage-81%25%2B%20enforced-green.svg)](#commands)
[![License: Proprietary](https://img.shields.io/badge/License-Proprietary-red.svg)](LICENSE)

## Install

```bash
pip install -e ".[dev]"
```

Requires Python 3.11, 3.12, or 3.13.

### Install the CLI globally (uv)

To get the `cobol-parser` command on your `PATH` in any directory, without
setting up a project virtualenv:

```bash
uv tool install .            # from a clone of this repo
uv tool install --editable . # dev mode: picks up code changes without reinstalling
```

`uv tool install` builds the Cython fast-path extensions as part of the
install, so the CLI runs at full speed. Verify it worked from anywhere:

```bash
cobol-parser --version
```

After pulling new commits (non-editable install only), rerun `uv tool install . --reinstall` to update.

## Quick Start

```python
from cobolparser import parse_cobol

result = parse_cobol(source, filename="prog.cbl")
if result.success:
    print(result.ast.program_name)
    print(result.ast.to_json())
```

CLI:

```bash
cobol-parser parse program.cbl
cobol-parser analyze program.cbl      # dynamic call analysis
cobol-parser dead-code program.cbl    # unreferenced paragraphs
```

### Generate test data from a copybook

`gen-data` turns a copybook record layout into a CSV of synthetic records —
one column per elementary field, values that always fit the field's PICTURE,
`USAGE`, and level-88 domain:

```bash
cobol-parser gen-data CUSTOMER.cpy --rows 100 --seed 7 -o customers.csv
```

```python
from cobolparser.generators import CopybookDataGenerator, DataGeneratorOptions

dataset = CopybookDataGenerator(
    DataGeneratorOptions(rows=100, seed=7)
).generate_from_file("CUSTOMER.cpy")
print(dataset.to_csv())
```

A `seed` makes output byte-identical across runs; omit it and the seed that
was drawn is reported on `dataset.seed` (and by `gen-data --describe`) so any
run can be replayed. `REDEFINES` and `FILLER` are excluded by default, and
`OCCURS` tables expand to one column per occurrence.

## Commands

```bash
# Tests
python -m pytest tests/ -v
python -m pytest --cov=cobolparser --cov-report=html

# Lint / format / type-check
ruff check .
black .
mypy cobolparser/
```

## Documentation

Full reference: [`.okf/index.md`](.okf/index.md)

## License

Proprietary — Copyright © 2026 Samuel Dion. All rights reserved. See [LICENSE](LICENSE).
