Metadata-Version: 2.1
Name: cypyc
Version: 0.1.0
Summary: Cypy compiler - A Python-like language that compiles to Cython
Home-page: https://github.com/cypy-lang/cypyc
Author: Cypy Team
Author-email: Cypy Team <dev@cypy.dev>
License: MIT License
        
        Copyright (c) 2026 Cypy Team
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Keywords: compiler,cython,transpiler
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
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 :: Compilers
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Cython >=3.0.0
Requires-Dist: setuptools >=60.0
Requires-Dist: watchdog >=3.0.0
Provides-Extra: dev
Requires-Dist: pytest >=7.0 ; extra == 'dev'
Requires-Dist: pytest-cov >=4.0 ; extra == 'dev'
Requires-Dist: black >=23.0 ; extra == 'dev'
Requires-Dist: flake8 >=6.0 ; extra == 'dev'
Requires-Dist: mypy >=1.0 ; extra == 'dev'

# Cypy

A Python-like language that compiles to Cython.

## Features

- **Python Compatibility**: Partial Python syntax compatibility
- **Gradual Typing**: Annotated variables use static types, unannotated fall back to `object`
- **Compile-time Checking**: `cypyc` transpiler catches type errors early
- **Cython Backend**: Compiles to Cython for high-performance C code
- **Modern Syntax**: Pattern matching, enum, struct, trait, let/var, and more
- **Concurrency**: `go` keyword for coroutines, `spawn` for threads
- **Pipe Operator**: `|>` for function chaining
- **List Comprehensions**: Full support with nested loops and conditions

## Quick Start

```bash
# Install dependencies
pip install -e .

# Transpile a Cypy file
cypyc input.cypy

# Transpile and compile
cypyc --compile input.cypy

# Type check only
cypyc --check input.cypy
```

## Syntax Examples

### Structs
```python
struct Point:
    x: float
    y: float
    
    def distance(self, other: Point) -> float:
        return ((self.x - other.x) ** 2 + (self.y - other.y) ** 2) ** 0.5
```

### Pattern Matching
```python
match value:
    case 1:
        return "one"
    case (a, b):
        return f"tuple: {a}, {b}"
    case _:
        return "other"
```

### Enum
```python
enum Color:
    Red
    Green
    Blue

def process_color(c: Color) -> int:
    match c:
        case Color.Red:
            return 1
        case _:
            return 0
```

### Let/Var Variables
```python
let x: int = 10  # Immutable, cannot be reassigned
var y: int = 20  # Mutable, can be reassigned
```

### Pipe Operator
```python
let result = 5 |> double |> square  # equivalent to square(double(5))
```

### Go (Coroutines) and Spawn (Threads)
```python
let task = go fetch_data(url)  # asyncio.create_task
let thread = spawn heavy_computation()  # threading.Thread
```

### List Comprehensions
```python
let squares = [x ** 2 for x in range(10) if x % 2 == 0]
```

## Documentation

- [SYNTAX_IMPLEMENTATION_STATUS.md](SYNTAX_IMPLEMENTATION_STATUS.md) - 语法实现状态报告
- [SYNTAX/00-introduction.md](SYNTAX/00-introduction.md) - 语言介绍
- [SYNTAX/01-basic-types.md](SYNTAX/01-basic-types.md) - 基础类型
- [SYNTAX/02-type-annotations.md](SYNTAX/02-type-annotations.md) - 类型注解
- [SYNTAX/05-struct.md](SYNTAX/05-struct.md) - 结构体
- [SYNTAX/06-enum.md](SYNTAX/06-enum.md) - 枚举
- [SYNTAX/07-trait-impl.md](SYNTAX/07-trait-impl.md) - 特质系统
- [SYNTAX/09-functions.md](SYNTAX/09-functions.md) - 函数
- [SYNTAX/10-variables.md](SYNTAX/10-variables.md) - 变量
- [SYNTAX/20-concurrency.md](SYNTAX/20-concurrency.md) - 并发
- [SYNTAX/23-compilation.md](SYNTAX/23-compilation.md) - 编译系统

## Project-Level Compilation

```bash
# Build entire project with cross-module type inference
cypyc build <project_directory>

# Build with specific entry point
cypyc build <project_directory> --entry main

# Type check only
cypyc build <project_directory> --check-only
```

## Examples

Explore the [examples/](examples/) directory for code examples:

- [basic_types.cypy](examples/basic_types.cypy) - Basic types and type conversion
- [control_flow.cypy](examples/control_flow.cypy) - Control flow statements
- [functions.cypy](examples/functions.cypy) - Functions and pipe operator
- [struct_enum.cypy](examples/struct_enum.cypy) - Structs and enums
- [concurrency.cypy](examples/concurrency.cypy) - Coroutines and threads
- [list_comprehension.cypy](examples/list_comprehension.cypy) - List comprehensions

## Testing

```bash
python scripts/run_tests.py
```

## License

MIT
