Metadata-Version: 2.4
Name: antlr-v4-linter
Version: 0.1.0
Summary: A comprehensive static analysis linter for ANTLR v4 grammar files
Author-email: Bytebase <support@bytebase.com>
Maintainer-email: Bytebase Team <support@bytebase.com>
License: MIT
Project-URL: Homepage, https://github.com/bytebase/antlr-v4-linter
Project-URL: Documentation, https://github.com/bytebase/antlr-v4-linter#readme
Project-URL: Repository, https://github.com/bytebase/antlr-v4-linter
Project-URL: Issues, https://github.com/bytebase/antlr-v4-linter/issues
Project-URL: Changelog, https://github.com/bytebase/antlr-v4-linter/releases
Keywords: antlr,antlr4,linter,grammar,parser,lexer,static-analysis
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8.1
Description-Content-Type: text/markdown
Requires-Dist: antlr4-python3-runtime>=4.13.0
Requires-Dist: click>=8.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: rich>=13.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: isort>=5.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"

# ANTLR v4 Grammar Linter

A comprehensive static analysis linter for ANTLR v4 grammar files (.g4) that identifies common issues, enforces best practices, and improves grammar quality and maintainability.

## Features

- **24 Built-in Rules** across 8 categories
- **Configurable Rule Severity** and thresholds
- **Multiple Output Formats** (JSON, XML, text, SARIF)
- **Auto-fixing** capabilities for deterministic issues
- **CLI and Programmatic APIs**
- **IDE Integration** ready

## Installation

```bash
pip install antlr-v4-linter
```

## Quick Start

```bash
# Lint a single grammar file
antlr-lint MyGrammar.g4

# Lint multiple files
antlr-lint src/**/*.g4

# Custom configuration
antlr-lint --config antlr-lint.json MyGrammar.g4

# JSON output
antlr-lint --format json MyGrammar.g4
```

## Rule Categories

1. **Syntax and Structure** (S001-S003)
2. **Naming and Convention** (N001-N003)  
3. **Labeling and Organization** (L001-L003)
4. **Complexity and Maintainability** (C001-C003)
5. **Token and Lexer** (T001-T003)
6. **Error Handling** (E001-E002)
7. **Performance** (P001-P002)
8. **Documentation** (D001-D002)

## Configuration

Create an `antlr-lint.json` file:

```json
{
  "rules": {
    "S001": { "enabled": true, "severity": "error" },
    "N001": { "enabled": true, "severity": "error" },
    "C001": { 
      "enabled": true, 
      "severity": "warning",
      "thresholds": {
        "maxAlternatives": 10,
        "maxNestingDepth": 5,
        "maxTokens": 50
      }
    }
  },
  "excludePatterns": ["*.generated.g4"],
  "outputFormat": "text"
}
```

## Development

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

# Run tests
pytest

# Format code
black src/ tests/
isort src/ tests/

# Type checking
mypy src/
```

## License

MIT License
