rpy-roblox 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rpy_roblox-1.0.0/LICENSE +21 -0
- rpy_roblox-1.0.0/PKG-INFO +166 -0
- rpy_roblox-1.0.0/README.md +143 -0
- rpy_roblox-1.0.0/cli/__init__.py +3 -0
- rpy_roblox-1.0.0/cli/main.py +1664 -0
- rpy_roblox-1.0.0/cli/watcher.py +167 -0
- rpy_roblox-1.0.0/pyproject.toml +44 -0
- rpy_roblox-1.0.0/rpy_roblox.egg-info/PKG-INFO +166 -0
- rpy_roblox-1.0.0/rpy_roblox.egg-info/SOURCES.txt +100 -0
- rpy_roblox-1.0.0/rpy_roblox.egg-info/dependency_links.txt +1 -0
- rpy_roblox-1.0.0/rpy_roblox.egg-info/entry_points.txt +2 -0
- rpy_roblox-1.0.0/rpy_roblox.egg-info/requires.txt +6 -0
- rpy_roblox-1.0.0/rpy_roblox.egg-info/top_level.txt +6 -0
- rpy_roblox-1.0.0/sdk/__init__.py +39 -0
- rpy_roblox-1.0.0/sdk/math.py +41 -0
- rpy_roblox-1.0.0/sdk/py.typed +0 -0
- rpy_roblox-1.0.0/sdk/roblox.py +691 -0
- rpy_roblox-1.0.0/sdk/rpy_roblox.pyi +47 -0
- rpy_roblox-1.0.0/sdk/stdlib/base64.py +13 -0
- rpy_roblox-1.0.0/sdk/stdlib/json.py +12 -0
- rpy_roblox-1.0.0/sdk/stdlib/math.py +57 -0
- rpy_roblox-1.0.0/sdk/string.py +24 -0
- rpy_roblox-1.0.0/sdk/table.py +19 -0
- rpy_roblox-1.0.0/sdk/task.py +11 -0
- rpy_roblox-1.0.0/server/__init__.py +3 -0
- rpy_roblox-1.0.0/server/lsp_server.py +282 -0
- rpy_roblox-1.0.0/setup.cfg +4 -0
- rpy_roblox-1.0.0/sync/__init__.py +1 -0
- rpy_roblox-1.0.0/sync/coordinator.py +143 -0
- rpy_roblox-1.0.0/sync/server.py +163 -0
- rpy_roblox-1.0.0/sync/watcher.py +53 -0
- rpy_roblox-1.0.0/tests/test_break_continue.py +139 -0
- rpy_roblox-1.0.0/tests/test_canonicalizer_safety.py +170 -0
- rpy_roblox-1.0.0/tests/test_cfg_validator.py +114 -0
- rpy_roblox-1.0.0/tests/test_constfold.py +5 -0
- rpy_roblox-1.0.0/tests/test_containers.py +10 -0
- rpy_roblox-1.0.0/tests/test_diagnostics_validation.py +37 -0
- rpy_roblox-1.0.0/tests/test_evil_suite.py +86 -0
- rpy_roblox-1.0.0/tests/test_explain.py +9 -0
- rpy_roblox-1.0.0/tests/test_fuzzer_v2.py +100 -0
- rpy_roblox-1.0.0/tests/test_golden.py +58 -0
- rpy_roblox-1.0.0/tests/test_imports.py +16 -0
- rpy_roblox-1.0.0/tests/test_lsp_queries.py +49 -0
- rpy_roblox-1.0.0/tests/test_nested_loops.py +87 -0
- rpy_roblox-1.0.0/tests/test_paren_reduction.py +87 -0
- rpy_roblox-1.0.0/tests/test_phase_a.py +21 -0
- rpy_roblox-1.0.0/tests/test_redundant_temp.py +5 -0
- rpy_roblox-1.0.0/tests/test_s4.py +12 -0
- rpy_roblox-1.0.0/tests/test_s5_inference.py +45 -0
- rpy_roblox-1.0.0/tests/test_semantics_cli.py +53 -0
- rpy_roblox-1.0.0/tests/test_structure_collapse.py +68 -0
- rpy_roblox-1.0.0/transpiler/__init__.py +55 -0
- rpy_roblox-1.0.0/transpiler/backend/__init__.py +3 -0
- rpy_roblox-1.0.0/transpiler/backend/generator.py +1693 -0
- rpy_roblox-1.0.0/transpiler/backend/luau_ast.py +184 -0
- rpy_roblox-1.0.0/transpiler/backend/printer.py +487 -0
- rpy_roblox-1.0.0/transpiler/backend/restructurer.py +425 -0
- rpy_roblox-1.0.0/transpiler/backend/runtime_snippets.py +712 -0
- rpy_roblox-1.0.0/transpiler/frontend/__init__.py +3 -0
- rpy_roblox-1.0.0/transpiler/frontend/ast_utils.py +259 -0
- rpy_roblox-1.0.0/transpiler/frontend/handlers.py +37 -0
- rpy_roblox-1.0.0/transpiler/frontend/node_registry.py +157 -0
- rpy_roblox-1.0.0/transpiler/frontend/parser.py +71 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/__init__.py +3 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/cache_manager.py +49 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/compile_time_worker.py +95 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/dependency_graph.py +183 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/diagnostics.py +70 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/errors.py +182 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/flags.py +25 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/linter.py +116 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/logger.py +31 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/metadata_updater.py +110 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/package_manager.py +158 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/project_context.py +38 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/sdk_metadata.py +51 -0
- rpy_roblox-1.0.0/transpiler/infrastructure/visitor.py +102 -0
- rpy_roblox-1.0.0/transpiler/middleend/__init__.py +3 -0
- rpy_roblox-1.0.0/transpiler/middleend/analyzer.py +841 -0
- rpy_roblox-1.0.0/transpiler/middleend/cfg.py +75 -0
- rpy_roblox-1.0.0/transpiler/middleend/cfg_builder.py +318 -0
- rpy_roblox-1.0.0/transpiler/middleend/ir.py +346 -0
- rpy_roblox-1.0.0/transpiler/middleend/linearizer.py +108 -0
- rpy_roblox-1.0.0/transpiler/middleend/purity.py +152 -0
- rpy_roblox-1.0.0/transpiler/middleend/query_service.py +440 -0
- rpy_roblox-1.0.0/transpiler/middleend/ssa.py +1754 -0
- rpy_roblox-1.0.0/transpiler/middleend/structural_analysis.py +153 -0
- rpy_roblox-1.0.0/transpiler/middleend/type_inferrer.py +383 -0
- rpy_roblox-1.0.0/transpiler/optimization/__init__.py +3 -0
- rpy_roblox-1.0.0/transpiler/optimization/canonicalizer.py +397 -0
- rpy_roblox-1.0.0/transpiler/optimization/cfg_optimizer.py +40 -0
- rpy_roblox-1.0.0/transpiler/optimization/cfg_validator.py +223 -0
- rpy_roblox-1.0.0/transpiler/optimization/closure_opt.py +45 -0
- rpy_roblox-1.0.0/transpiler/optimization/escape_analysis.py +225 -0
- rpy_roblox-1.0.0/transpiler/optimization/ir_optimizer.py +120 -0
- rpy_roblox-1.0.0/transpiler/optimization/ir_transformer.py +671 -0
- rpy_roblox-1.0.0/transpiler/optimization/loop_detector.py +72 -0
- rpy_roblox-1.0.0/transpiler/optimization/peephole.py +337 -0
- rpy_roblox-1.0.0/transpiler/optimization/profiling_optimizer.py +60 -0
- rpy_roblox-1.0.0/transpiler/optimization/sra.py +185 -0
- rpy_roblox-1.0.0/transpiler/transformer.py +193 -0
- rpy_roblox-1.0.0/transpiler/version.py +1 -0
rpy_roblox-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RPy Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rpy-roblox
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python-to-Roblox Luau transpiler
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: roblox,luau,transpiler,compiler,python
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: watchdog>=3.0.0
|
|
18
|
+
Requires-Dist: aiohttp>=3.8.0
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
21
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# RPy
|
|
25
|
+
|
|
26
|
+
> A Python-to-Roblox Luau transpiler. Write game logic in Python; RPy compiles it to Luau that runs natively in Roblox Studio.
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```powershell
|
|
31
|
+
# Install
|
|
32
|
+
pip install -e ".[dev]"
|
|
33
|
+
|
|
34
|
+
# Scaffold a new project
|
|
35
|
+
rpy setup myproject
|
|
36
|
+
cd myproject
|
|
37
|
+
|
|
38
|
+
# Transpile a file
|
|
39
|
+
rpy transpile src/main.py out/main.lua
|
|
40
|
+
|
|
41
|
+
# Transpile a directory
|
|
42
|
+
rpy transpile src/ out/
|
|
43
|
+
|
|
44
|
+
# Live Sync (Dev Server + Watcher)
|
|
45
|
+
rpy live src/ out/
|
|
46
|
+
|
|
47
|
+
# Validate without writing output
|
|
48
|
+
rpy validate src/
|
|
49
|
+
|
|
50
|
+
# With type annotations
|
|
51
|
+
rpy build src/ out/ --typed --verbose
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Example
|
|
55
|
+
|
|
56
|
+
**Python (input):**
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from roblox import Instance, workspace, Vector3
|
|
60
|
+
|
|
61
|
+
class NPC:
|
|
62
|
+
def __init__(self, name, health):
|
|
63
|
+
self.name = name
|
|
64
|
+
self.health = health
|
|
65
|
+
|
|
66
|
+
def take_damage(self, amount):
|
|
67
|
+
self.health = self.health - amount
|
|
68
|
+
if self.health <= 0:
|
|
69
|
+
print(f"{self.name} defeated!")
|
|
70
|
+
|
|
71
|
+
guard = NPC("Guard", 100)
|
|
72
|
+
guard.take_damage(30)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Luau (output):**
|
|
76
|
+
|
|
77
|
+
```lua
|
|
78
|
+
-- Generated by RPy — do not edit manually
|
|
79
|
+
local _RT = require(script.Parent.python_runtime)
|
|
80
|
+
local py_str = _RT.py_str
|
|
81
|
+
|
|
82
|
+
local NPC = {}
|
|
83
|
+
NPC.__index = NPC
|
|
84
|
+
|
|
85
|
+
function NPC.new(name, health)
|
|
86
|
+
local self = setmetatable({}, NPC)
|
|
87
|
+
self.name = name
|
|
88
|
+
self.health = health
|
|
89
|
+
return self
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
function NPC:take_damage(amount)
|
|
93
|
+
self.health = (self.health - amount)
|
|
94
|
+
if (self.health <= 0) then
|
|
95
|
+
print(("" .. py_str(self.name) .. " defeated!"))
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
local guard = NPC.new("Guard", 100)
|
|
100
|
+
guard:take_damage(30)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Supported Python Subset (v1.0.0)
|
|
104
|
+
|
|
105
|
+
- **Variables & Logic**: Full support for variables, arithmetic, logical comparisons, and ternary operators.
|
|
106
|
+
- **Control Flow**: `if` / `elif` / `else`, `while`, and specialized `for i in range()` loops.
|
|
107
|
+
- **Functions**: Support for `def`, `return`, `lambda`, and `*args`.
|
|
108
|
+
- **Data Structures**: Lists, Dicts, and Tuples with 40+ method remaps to Luau's `table` library.
|
|
109
|
+
- **Async & Task**: Built-in `task` module support for `task.wait()`, `task.spawn()`, and `task.delay()`.
|
|
110
|
+
- **Standard Library**: Native mapping for `math`, `string`, `table`, `coroutine`, and `debug` libraries.
|
|
111
|
+
- **Roblox SDK**: Integrated `roblox` stubs for 100+ services and classes with autocompletion support.
|
|
112
|
+
- **Modern OOP**: Single inheritance classes with metatable-based state management.
|
|
113
|
+
- **Error Handling**: Full `try` / `except` / `finally` blocks transpiled to Luau `pcall`.
|
|
114
|
+
- **Package Management**: Native Wally integration via `rpy install` for Luau dependencies.
|
|
115
|
+
- **Intelligence Layer**: Fuzzy property suggestions, flow-sensitive type refinement, and nil-safety diagnostics.
|
|
116
|
+
- **Advanced Performance**: Compile-time macros (`@compile_time`), Recursive DCE, CSE, and LICM optimizations.
|
|
117
|
+
|
|
118
|
+
## Compiler Flags
|
|
119
|
+
|
|
120
|
+
| Flag | Effect |
|
|
121
|
+
|---|---|
|
|
122
|
+
| `--typed` | Emit Luau type annotations (`local x: number = 5`) |
|
|
123
|
+
| `--fast` | Skip `py_bool()` truthiness shim (Lua semantics) |
|
|
124
|
+
| `--no-runtime` | Don't prepend runtime `require()` |
|
|
125
|
+
| `--compile-time` | Enable build-time Python execution (Macros) |
|
|
126
|
+
| `--debug` | Enable detailed diagnostic logging |
|
|
127
|
+
| `--verbose` | Print detailed build output |
|
|
128
|
+
|
|
129
|
+
| Command | Description |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `rpy transpile <src> <out>` | Transpile files/directories (Alias: `build`) |
|
|
132
|
+
| `rpy validate <src>` | Validate without writing output (Alias: `check`) |
|
|
133
|
+
| `rpy setup [dir]` | Scaffold a new RPy project (Alias: `init`) |
|
|
134
|
+
| `rpy live <src> <out>` | Real-time Dev Server & Studio Sync (Alias: `watch`) |
|
|
135
|
+
|
|
136
|
+
## Project Structure
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
RPy/
|
|
140
|
+
├── transpiler/ # Compiler pipeline
|
|
141
|
+
│ ├── parser.py # Python source → AST
|
|
142
|
+
│ ├── transformer.py # Scope analysis, import resolution
|
|
143
|
+
│ ├── generator.py # AST → Luau code generation
|
|
144
|
+
│ ├── type_inferrer.py # Type inference for --typed mode
|
|
145
|
+
│ ├── errors.py # Custom error hierarchy
|
|
146
|
+
│ └── ast_utils.py # AST utility functions
|
|
147
|
+
├── runtime/
|
|
148
|
+
│ └── python_runtime.lua # Luau runtime helpers (40+ functions)
|
|
149
|
+
├── sdk/
|
|
150
|
+
│ └── roblox.py # IDE stubs for Roblox APIs (30+ services)
|
|
151
|
+
├── cli/
|
|
152
|
+
│ └── main.py # CLI entry point (build/check/init/watch)
|
|
153
|
+
├── examples/ # Example RPy scripts
|
|
154
|
+
├── docs/ # Documentation
|
|
155
|
+
└── tests/ # 280+ unit & integration tests
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Documentation
|
|
159
|
+
|
|
160
|
+
- [`docs/supported_subset.md`](docs/supported_subset.md) — Exact Python feature list
|
|
161
|
+
- [`docs/semantic_map.md`](docs/semantic_map.md) — Python → Luau mapping reference
|
|
162
|
+
- [`docs/runtime_api.md`](docs/runtime_api.md) — Runtime helper function signatures
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# RPy
|
|
2
|
+
|
|
3
|
+
> A Python-to-Roblox Luau transpiler. Write game logic in Python; RPy compiles it to Luau that runs natively in Roblox Studio.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```powershell
|
|
8
|
+
# Install
|
|
9
|
+
pip install -e ".[dev]"
|
|
10
|
+
|
|
11
|
+
# Scaffold a new project
|
|
12
|
+
rpy setup myproject
|
|
13
|
+
cd myproject
|
|
14
|
+
|
|
15
|
+
# Transpile a file
|
|
16
|
+
rpy transpile src/main.py out/main.lua
|
|
17
|
+
|
|
18
|
+
# Transpile a directory
|
|
19
|
+
rpy transpile src/ out/
|
|
20
|
+
|
|
21
|
+
# Live Sync (Dev Server + Watcher)
|
|
22
|
+
rpy live src/ out/
|
|
23
|
+
|
|
24
|
+
# Validate without writing output
|
|
25
|
+
rpy validate src/
|
|
26
|
+
|
|
27
|
+
# With type annotations
|
|
28
|
+
rpy build src/ out/ --typed --verbose
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
|
|
33
|
+
**Python (input):**
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from roblox import Instance, workspace, Vector3
|
|
37
|
+
|
|
38
|
+
class NPC:
|
|
39
|
+
def __init__(self, name, health):
|
|
40
|
+
self.name = name
|
|
41
|
+
self.health = health
|
|
42
|
+
|
|
43
|
+
def take_damage(self, amount):
|
|
44
|
+
self.health = self.health - amount
|
|
45
|
+
if self.health <= 0:
|
|
46
|
+
print(f"{self.name} defeated!")
|
|
47
|
+
|
|
48
|
+
guard = NPC("Guard", 100)
|
|
49
|
+
guard.take_damage(30)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Luau (output):**
|
|
53
|
+
|
|
54
|
+
```lua
|
|
55
|
+
-- Generated by RPy — do not edit manually
|
|
56
|
+
local _RT = require(script.Parent.python_runtime)
|
|
57
|
+
local py_str = _RT.py_str
|
|
58
|
+
|
|
59
|
+
local NPC = {}
|
|
60
|
+
NPC.__index = NPC
|
|
61
|
+
|
|
62
|
+
function NPC.new(name, health)
|
|
63
|
+
local self = setmetatable({}, NPC)
|
|
64
|
+
self.name = name
|
|
65
|
+
self.health = health
|
|
66
|
+
return self
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
function NPC:take_damage(amount)
|
|
70
|
+
self.health = (self.health - amount)
|
|
71
|
+
if (self.health <= 0) then
|
|
72
|
+
print(("" .. py_str(self.name) .. " defeated!"))
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
local guard = NPC.new("Guard", 100)
|
|
77
|
+
guard:take_damage(30)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Supported Python Subset (v1.0.0)
|
|
81
|
+
|
|
82
|
+
- **Variables & Logic**: Full support for variables, arithmetic, logical comparisons, and ternary operators.
|
|
83
|
+
- **Control Flow**: `if` / `elif` / `else`, `while`, and specialized `for i in range()` loops.
|
|
84
|
+
- **Functions**: Support for `def`, `return`, `lambda`, and `*args`.
|
|
85
|
+
- **Data Structures**: Lists, Dicts, and Tuples with 40+ method remaps to Luau's `table` library.
|
|
86
|
+
- **Async & Task**: Built-in `task` module support for `task.wait()`, `task.spawn()`, and `task.delay()`.
|
|
87
|
+
- **Standard Library**: Native mapping for `math`, `string`, `table`, `coroutine`, and `debug` libraries.
|
|
88
|
+
- **Roblox SDK**: Integrated `roblox` stubs for 100+ services and classes with autocompletion support.
|
|
89
|
+
- **Modern OOP**: Single inheritance classes with metatable-based state management.
|
|
90
|
+
- **Error Handling**: Full `try` / `except` / `finally` blocks transpiled to Luau `pcall`.
|
|
91
|
+
- **Package Management**: Native Wally integration via `rpy install` for Luau dependencies.
|
|
92
|
+
- **Intelligence Layer**: Fuzzy property suggestions, flow-sensitive type refinement, and nil-safety diagnostics.
|
|
93
|
+
- **Advanced Performance**: Compile-time macros (`@compile_time`), Recursive DCE, CSE, and LICM optimizations.
|
|
94
|
+
|
|
95
|
+
## Compiler Flags
|
|
96
|
+
|
|
97
|
+
| Flag | Effect |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `--typed` | Emit Luau type annotations (`local x: number = 5`) |
|
|
100
|
+
| `--fast` | Skip `py_bool()` truthiness shim (Lua semantics) |
|
|
101
|
+
| `--no-runtime` | Don't prepend runtime `require()` |
|
|
102
|
+
| `--compile-time` | Enable build-time Python execution (Macros) |
|
|
103
|
+
| `--debug` | Enable detailed diagnostic logging |
|
|
104
|
+
| `--verbose` | Print detailed build output |
|
|
105
|
+
|
|
106
|
+
| Command | Description |
|
|
107
|
+
|---|---|
|
|
108
|
+
| `rpy transpile <src> <out>` | Transpile files/directories (Alias: `build`) |
|
|
109
|
+
| `rpy validate <src>` | Validate without writing output (Alias: `check`) |
|
|
110
|
+
| `rpy setup [dir]` | Scaffold a new RPy project (Alias: `init`) |
|
|
111
|
+
| `rpy live <src> <out>` | Real-time Dev Server & Studio Sync (Alias: `watch`) |
|
|
112
|
+
|
|
113
|
+
## Project Structure
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
RPy/
|
|
117
|
+
├── transpiler/ # Compiler pipeline
|
|
118
|
+
│ ├── parser.py # Python source → AST
|
|
119
|
+
│ ├── transformer.py # Scope analysis, import resolution
|
|
120
|
+
│ ├── generator.py # AST → Luau code generation
|
|
121
|
+
│ ├── type_inferrer.py # Type inference for --typed mode
|
|
122
|
+
│ ├── errors.py # Custom error hierarchy
|
|
123
|
+
│ └── ast_utils.py # AST utility functions
|
|
124
|
+
├── runtime/
|
|
125
|
+
│ └── python_runtime.lua # Luau runtime helpers (40+ functions)
|
|
126
|
+
├── sdk/
|
|
127
|
+
│ └── roblox.py # IDE stubs for Roblox APIs (30+ services)
|
|
128
|
+
├── cli/
|
|
129
|
+
│ └── main.py # CLI entry point (build/check/init/watch)
|
|
130
|
+
├── examples/ # Example RPy scripts
|
|
131
|
+
├── docs/ # Documentation
|
|
132
|
+
└── tests/ # 280+ unit & integration tests
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Documentation
|
|
136
|
+
|
|
137
|
+
- [`docs/supported_subset.md`](docs/supported_subset.md) — Exact Python feature list
|
|
138
|
+
- [`docs/semantic_map.md`](docs/semantic_map.md) — Python → Luau mapping reference
|
|
139
|
+
- [`docs/runtime_api.md`](docs/runtime_api.md) — Runtime helper function signatures
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|