RedPanda-transpiler 0.1.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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.4
2
+ Name: RedPanda-transpiler
3
+ Version: 0.1.0
4
+ Summary: A Python to Mandarin Chinese transpiler.
5
+ Author: fmasterpro27
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Fmasterpro27/RedPanda-transpiler
8
+ Project-URL: Repository, https://github.com/Fmasterpro27/RedPanda-transpiler
9
+ Project-URL: Issues, https://github.com/Fmasterpro27/RedPanda-transpiler/issues
10
+ Keywords: python,transpiler,compiler,parser,mandarin,chinese,language,codegen,redpanda
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Compilers
14
+ Classifier: Topic :: Software Development :: Interpreters
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Operating System :: OS Independent
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+ Dynamic: requires-python
25
+
26
+ # 🐼 RedPanda Transpiler
27
+
28
+ <p align="center">
29
+ <img src="https://raw.githubusercontent.com/Fmasterpro27/RedPanda-transpiler/main/assets/redpanda.png"
30
+ alt="RedPanda Transpiler logo"
31
+ width="250">
32
+ </p>
33
+
34
+ > A Python → Mandarin Chinese transpiler.
35
+
36
+ RedPanda is an experimental transpiler that converts standard Python syntax into readable Mandarin Chinese syntax while preserving the program's structure. It is designed for educational purposes, language learning, and experimentation with localized programming syntax.
37
+
38
+ > **Project Status:** 🚧 Alpha (v0.1.0)
39
+
40
+ ---
41
+
42
+ ## Features
43
+
44
+ - Translate Python keywords into Mandarin Chinese
45
+ - Translate built-in functions
46
+ - Translate Python constants
47
+ - Simple command-line interface
48
+ - Lightweight with no external dependencies
49
+ - Compatible with Python 3.11+
50
+
51
+ ---
52
+
53
+ ## Example
54
+
55
+ ### Python
56
+
57
+ ```python
58
+ print("Hello, World!")
59
+
60
+ if True:
61
+ print(len([1, 2, 3]))
62
+
63
+ for i in range(5):
64
+ print(i)
65
+ ```
66
+
67
+ ### Output
68
+
69
+ ```python
70
+ 打印("Hello, World!")
71
+
72
+ 如果 真:
73
+ 打印(长度([1, 2, 3]))
74
+
75
+ 对于 i 于 范围(5):
76
+ 打印(i)
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Installation
82
+
83
+ Install RedPanda Transpiler from PyPI:
84
+
85
+ ```bash
86
+ pip install redpanda-transpiler
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Usage
92
+
93
+ Transpile a file:
94
+
95
+ ```bash
96
+ redpanda-tr input.py
97
+ ```
98
+
99
+ Write the output to another file:
100
+
101
+ ```bash
102
+ redpanda-tr input.py -o output.py
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Project Structure
108
+
109
+ ```
110
+ RedPanda-transpiler/
111
+
112
+ ├── redpanda/
113
+ │ ├── cli.py
114
+ │ ├── loader.py
115
+ │ ├── transpiler.py
116
+ │ ├── __main__.py
117
+ │ ├── __init__.py
118
+ │ └── data/
119
+ │ ├── keywords.json
120
+ │ ├── builtins.json
121
+ │ └── constants.json
122
+
123
+ ├── pyproject.toml
124
+ ├── README.md
125
+ ├── LICENSE
126
+ └── setup.py
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Supported Translations
132
+
133
+ ### Keywords
134
+
135
+ | Python | Mandarin |
136
+ | ------- | -------- |
137
+ | if | 如果 |
138
+ | else | 否则 |
139
+ | elif | 否则如果 |
140
+ | for | 对于 |
141
+ | while | 当 |
142
+ | def | 定义 |
143
+ | class | 类 |
144
+ | return | 返回 |
145
+ | import | 导入 |
146
+ | from | 从 |
147
+ | as | 作为 |
148
+ | try | 尝试 |
149
+ | except | 异常 |
150
+ | finally | 最后 |
151
+
152
+ ### Built-ins
153
+
154
+ | Python | Mandarin |
155
+ | ------ | -------- |
156
+ | print | 打印 |
157
+ | input | 输入 |
158
+ | len | 长度 |
159
+ | range | 范围 |
160
+ | list | 列表 |
161
+ | dict | 字典 |
162
+ | tuple | 元组 |
163
+ | set | 集合 |
164
+
165
+ ### Constants
166
+
167
+ | Python | Mandarin |
168
+ | ------ | -------- |
169
+ | True | 真 |
170
+ | False | 假 |
171
+ | None | 空 |
172
+
173
+ ---
174
+
175
+ ## Roadmap
176
+
177
+ - [x] Command-line interface
178
+ - [x] Keyword translation
179
+ - [x] Built-in translation
180
+ - [x] Constant translation
181
+ - [x] Tokenizer-based transpiler
182
+ - [ ] AST-based transpiler
183
+ - [ ] Reverse transpiler (Mandarin → Python)
184
+ - [ ] Comment translation
185
+ - [ ] Docstring translation
186
+ - [ ] F-string support
187
+ - [ ] Package import translation
188
+ - [ ] Comprehensive unit tests
189
+ - [ ] CI/CD with GitHub Actions
190
+
191
+ ---
192
+
193
+ ## License
194
+
195
+ This project is licensed under the Apache License 2.0.
196
+
197
+ See the `LICENSE` file for details.
198
+
199
+ ---
200
+
201
+ ## Disclaimer
202
+
203
+ RedPanda is an experimental project intended for education and research. The generated Mandarin syntax is **not executable by the standard Python interpreter**. It must be converted back to standard Python or interpreted by a compatible tool.
204
+
205
+ ---
206
+
207
+ ## Author
208
+
209
+ **fmasterpro27**
210
+
211
+ GitHub: https://github.com/Fmasterpro27
212
+
213
+ ---
214
+
215
+ If you find this project useful, consider giving it a ⭐ on GitHub!
@@ -0,0 +1,190 @@
1
+ # 🐼 RedPanda Transpiler
2
+
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/Fmasterpro27/RedPanda-transpiler/main/assets/redpanda.png"
5
+ alt="RedPanda Transpiler logo"
6
+ width="250">
7
+ </p>
8
+
9
+ > A Python → Mandarin Chinese transpiler.
10
+
11
+ RedPanda is an experimental transpiler that converts standard Python syntax into readable Mandarin Chinese syntax while preserving the program's structure. It is designed for educational purposes, language learning, and experimentation with localized programming syntax.
12
+
13
+ > **Project Status:** 🚧 Alpha (v0.1.0)
14
+
15
+ ---
16
+
17
+ ## Features
18
+
19
+ - Translate Python keywords into Mandarin Chinese
20
+ - Translate built-in functions
21
+ - Translate Python constants
22
+ - Simple command-line interface
23
+ - Lightweight with no external dependencies
24
+ - Compatible with Python 3.11+
25
+
26
+ ---
27
+
28
+ ## Example
29
+
30
+ ### Python
31
+
32
+ ```python
33
+ print("Hello, World!")
34
+
35
+ if True:
36
+ print(len([1, 2, 3]))
37
+
38
+ for i in range(5):
39
+ print(i)
40
+ ```
41
+
42
+ ### Output
43
+
44
+ ```python
45
+ 打印("Hello, World!")
46
+
47
+ 如果 真:
48
+ 打印(长度([1, 2, 3]))
49
+
50
+ 对于 i 于 范围(5):
51
+ 打印(i)
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Installation
57
+
58
+ Install RedPanda Transpiler from PyPI:
59
+
60
+ ```bash
61
+ pip install redpanda-transpiler
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Usage
67
+
68
+ Transpile a file:
69
+
70
+ ```bash
71
+ redpanda-tr input.py
72
+ ```
73
+
74
+ Write the output to another file:
75
+
76
+ ```bash
77
+ redpanda-tr input.py -o output.py
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Project Structure
83
+
84
+ ```
85
+ RedPanda-transpiler/
86
+
87
+ ├── redpanda/
88
+ │ ├── cli.py
89
+ │ ├── loader.py
90
+ │ ├── transpiler.py
91
+ │ ├── __main__.py
92
+ │ ├── __init__.py
93
+ │ └── data/
94
+ │ ├── keywords.json
95
+ │ ├── builtins.json
96
+ │ └── constants.json
97
+
98
+ ├── pyproject.toml
99
+ ├── README.md
100
+ ├── LICENSE
101
+ └── setup.py
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Supported Translations
107
+
108
+ ### Keywords
109
+
110
+ | Python | Mandarin |
111
+ | ------- | -------- |
112
+ | if | 如果 |
113
+ | else | 否则 |
114
+ | elif | 否则如果 |
115
+ | for | 对于 |
116
+ | while | 当 |
117
+ | def | 定义 |
118
+ | class | 类 |
119
+ | return | 返回 |
120
+ | import | 导入 |
121
+ | from | 从 |
122
+ | as | 作为 |
123
+ | try | 尝试 |
124
+ | except | 异常 |
125
+ | finally | 最后 |
126
+
127
+ ### Built-ins
128
+
129
+ | Python | Mandarin |
130
+ | ------ | -------- |
131
+ | print | 打印 |
132
+ | input | 输入 |
133
+ | len | 长度 |
134
+ | range | 范围 |
135
+ | list | 列表 |
136
+ | dict | 字典 |
137
+ | tuple | 元组 |
138
+ | set | 集合 |
139
+
140
+ ### Constants
141
+
142
+ | Python | Mandarin |
143
+ | ------ | -------- |
144
+ | True | 真 |
145
+ | False | 假 |
146
+ | None | 空 |
147
+
148
+ ---
149
+
150
+ ## Roadmap
151
+
152
+ - [x] Command-line interface
153
+ - [x] Keyword translation
154
+ - [x] Built-in translation
155
+ - [x] Constant translation
156
+ - [x] Tokenizer-based transpiler
157
+ - [ ] AST-based transpiler
158
+ - [ ] Reverse transpiler (Mandarin → Python)
159
+ - [ ] Comment translation
160
+ - [ ] Docstring translation
161
+ - [ ] F-string support
162
+ - [ ] Package import translation
163
+ - [ ] Comprehensive unit tests
164
+ - [ ] CI/CD with GitHub Actions
165
+
166
+ ---
167
+
168
+ ## License
169
+
170
+ This project is licensed under the Apache License 2.0.
171
+
172
+ See the `LICENSE` file for details.
173
+
174
+ ---
175
+
176
+ ## Disclaimer
177
+
178
+ RedPanda is an experimental project intended for education and research. The generated Mandarin syntax is **not executable by the standard Python interpreter**. It must be converted back to standard Python or interpreted by a compatible tool.
179
+
180
+ ---
181
+
182
+ ## Author
183
+
184
+ **fmasterpro27**
185
+
186
+ GitHub: https://github.com/Fmasterpro27
187
+
188
+ ---
189
+
190
+ If you find this project useful, consider giving it a ⭐ on GitHub!
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.4
2
+ Name: RedPanda-transpiler
3
+ Version: 0.1.0
4
+ Summary: A Python to Mandarin Chinese transpiler.
5
+ Author: fmasterpro27
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Fmasterpro27/RedPanda-transpiler
8
+ Project-URL: Repository, https://github.com/Fmasterpro27/RedPanda-transpiler
9
+ Project-URL: Issues, https://github.com/Fmasterpro27/RedPanda-transpiler/issues
10
+ Keywords: python,transpiler,compiler,parser,mandarin,chinese,language,codegen,redpanda
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Compilers
14
+ Classifier: Topic :: Software Development :: Interpreters
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Operating System :: OS Independent
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+ Dynamic: requires-python
25
+
26
+ # 🐼 RedPanda Transpiler
27
+
28
+ <p align="center">
29
+ <img src="https://raw.githubusercontent.com/Fmasterpro27/RedPanda-transpiler/main/assets/redpanda.png"
30
+ alt="RedPanda Transpiler logo"
31
+ width="250">
32
+ </p>
33
+
34
+ > A Python → Mandarin Chinese transpiler.
35
+
36
+ RedPanda is an experimental transpiler that converts standard Python syntax into readable Mandarin Chinese syntax while preserving the program's structure. It is designed for educational purposes, language learning, and experimentation with localized programming syntax.
37
+
38
+ > **Project Status:** 🚧 Alpha (v0.1.0)
39
+
40
+ ---
41
+
42
+ ## Features
43
+
44
+ - Translate Python keywords into Mandarin Chinese
45
+ - Translate built-in functions
46
+ - Translate Python constants
47
+ - Simple command-line interface
48
+ - Lightweight with no external dependencies
49
+ - Compatible with Python 3.11+
50
+
51
+ ---
52
+
53
+ ## Example
54
+
55
+ ### Python
56
+
57
+ ```python
58
+ print("Hello, World!")
59
+
60
+ if True:
61
+ print(len([1, 2, 3]))
62
+
63
+ for i in range(5):
64
+ print(i)
65
+ ```
66
+
67
+ ### Output
68
+
69
+ ```python
70
+ 打印("Hello, World!")
71
+
72
+ 如果 真:
73
+ 打印(长度([1, 2, 3]))
74
+
75
+ 对于 i 于 范围(5):
76
+ 打印(i)
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Installation
82
+
83
+ Install RedPanda Transpiler from PyPI:
84
+
85
+ ```bash
86
+ pip install redpanda-transpiler
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Usage
92
+
93
+ Transpile a file:
94
+
95
+ ```bash
96
+ redpanda-tr input.py
97
+ ```
98
+
99
+ Write the output to another file:
100
+
101
+ ```bash
102
+ redpanda-tr input.py -o output.py
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Project Structure
108
+
109
+ ```
110
+ RedPanda-transpiler/
111
+
112
+ ├── redpanda/
113
+ │ ├── cli.py
114
+ │ ├── loader.py
115
+ │ ├── transpiler.py
116
+ │ ├── __main__.py
117
+ │ ├── __init__.py
118
+ │ └── data/
119
+ │ ├── keywords.json
120
+ │ ├── builtins.json
121
+ │ └── constants.json
122
+
123
+ ├── pyproject.toml
124
+ ├── README.md
125
+ ├── LICENSE
126
+ └── setup.py
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Supported Translations
132
+
133
+ ### Keywords
134
+
135
+ | Python | Mandarin |
136
+ | ------- | -------- |
137
+ | if | 如果 |
138
+ | else | 否则 |
139
+ | elif | 否则如果 |
140
+ | for | 对于 |
141
+ | while | 当 |
142
+ | def | 定义 |
143
+ | class | 类 |
144
+ | return | 返回 |
145
+ | import | 导入 |
146
+ | from | 从 |
147
+ | as | 作为 |
148
+ | try | 尝试 |
149
+ | except | 异常 |
150
+ | finally | 最后 |
151
+
152
+ ### Built-ins
153
+
154
+ | Python | Mandarin |
155
+ | ------ | -------- |
156
+ | print | 打印 |
157
+ | input | 输入 |
158
+ | len | 长度 |
159
+ | range | 范围 |
160
+ | list | 列表 |
161
+ | dict | 字典 |
162
+ | tuple | 元组 |
163
+ | set | 集合 |
164
+
165
+ ### Constants
166
+
167
+ | Python | Mandarin |
168
+ | ------ | -------- |
169
+ | True | 真 |
170
+ | False | 假 |
171
+ | None | 空 |
172
+
173
+ ---
174
+
175
+ ## Roadmap
176
+
177
+ - [x] Command-line interface
178
+ - [x] Keyword translation
179
+ - [x] Built-in translation
180
+ - [x] Constant translation
181
+ - [x] Tokenizer-based transpiler
182
+ - [ ] AST-based transpiler
183
+ - [ ] Reverse transpiler (Mandarin → Python)
184
+ - [ ] Comment translation
185
+ - [ ] Docstring translation
186
+ - [ ] F-string support
187
+ - [ ] Package import translation
188
+ - [ ] Comprehensive unit tests
189
+ - [ ] CI/CD with GitHub Actions
190
+
191
+ ---
192
+
193
+ ## License
194
+
195
+ This project is licensed under the Apache License 2.0.
196
+
197
+ See the `LICENSE` file for details.
198
+
199
+ ---
200
+
201
+ ## Disclaimer
202
+
203
+ RedPanda is an experimental project intended for education and research. The generated Mandarin syntax is **not executable by the standard Python interpreter**. It must be converted back to standard Python or interpreted by a compatible tool.
204
+
205
+ ---
206
+
207
+ ## Author
208
+
209
+ **fmasterpro27**
210
+
211
+ GitHub: https://github.com/Fmasterpro27
212
+
213
+ ---
214
+
215
+ If you find this project useful, consider giving it a ⭐ on GitHub!
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ RedPanda_transpiler.egg-info/PKG-INFO
6
+ RedPanda_transpiler.egg-info/SOURCES.txt
7
+ RedPanda_transpiler.egg-info/dependency_links.txt
8
+ RedPanda_transpiler.egg-info/entry_points.txt
9
+ RedPanda_transpiler.egg-info/top_level.txt
10
+ redpanda/__init__.py
11
+ redpanda/cli.py
12
+ redpanda/loader.py
13
+ redpanda/main.py
14
+ redpanda/transpiler.py
15
+ redpanda/data/builtins.json
16
+ redpanda/data/constants.json
17
+ redpanda/data/keywords.json
18
+ tests/test_transpiler.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ redpanda-tr = redpanda.cli:main
@@ -0,0 +1,57 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "RedPanda-transpiler"
7
+ version = "0.1.0"
8
+ description = "A Python to Mandarin Chinese transpiler."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.11"
13
+
14
+ authors = [{ name = "fmasterpro27" }]
15
+
16
+ keywords = [
17
+ "python",
18
+ "transpiler",
19
+ "compiler",
20
+ "parser",
21
+ "mandarin",
22
+ "chinese",
23
+ "language",
24
+ "codegen",
25
+ "redpanda",
26
+ ]
27
+
28
+ classifiers = [
29
+ "Development Status :: 3 - Alpha",
30
+ "Intended Audience :: Developers",
31
+ "Topic :: Software Development :: Compilers",
32
+ "Topic :: Software Development :: Interpreters",
33
+ "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Programming Language :: Python :: 3.13",
37
+ "Operating System :: OS Independent",
38
+ ]
39
+
40
+ dependencies = []
41
+
42
+ [project.scripts]
43
+ redpanda-tr = "redpanda.cli:main"
44
+
45
+ [project.urls]
46
+ Homepage = "https://github.com/Fmasterpro27/RedPanda-transpiler"
47
+ Repository = "https://github.com/Fmasterpro27/RedPanda-transpiler"
48
+ Issues = "https://github.com/Fmasterpro27/RedPanda-transpiler/issues"
49
+
50
+ [tool.setuptools]
51
+ include-package-data = true
52
+
53
+ [tool.setuptools.package-data]
54
+ redpanda = ["data/**/*.json"]
55
+
56
+ [tool.pytest.ini_options]
57
+ pythonpath = ["."]
@@ -0,0 +1,6 @@
1
+ from .transpiler import transpile_source, transpile_file
2
+
3
+ __all__ = [
4
+ "transpile_source",
5
+ "transpile_file",
6
+ ]
@@ -0,0 +1,59 @@
1
+ import argparse
2
+ from pathlib import Path
3
+
4
+ from .transpiler import transpile_file
5
+
6
+ OUTPUT_EXTENSION = ".panda"
7
+
8
+
9
+ def resolve_input_path(raw_input: str) -> Path:
10
+ input_path = Path(raw_input)
11
+ if input_path.exists():
12
+ return input_path
13
+
14
+ if input_path.drive == "" and raw_input.startswith(("/", "\\")):
15
+ relative_path = Path(raw_input.lstrip("/\\"))
16
+ if relative_path.exists():
17
+ return relative_path
18
+
19
+ return input_path
20
+
21
+
22
+ def main():
23
+ parser = argparse.ArgumentParser(
24
+ prog="redpanda-tr",
25
+ description="Python → Mandarin Chinese transpiler"
26
+ )
27
+
28
+ parser.add_argument(
29
+ "input",
30
+ help="path to the Python source file to transpile (.py)"
31
+ )
32
+
33
+ parser.add_argument(
34
+ "-o", "--output",
35
+ help=f"path to write the translated output to "
36
+ f"(defaults to <input>{OUTPUT_EXTENSION} if omitted)"
37
+ )
38
+
39
+ parser.add_argument(
40
+ "--stdout",
41
+ action="store_true",
42
+ help="write the transpiled source to stdout instead of a file",
43
+ )
44
+
45
+ args = parser.parse_args()
46
+
47
+ input_path = resolve_input_path(args.input)
48
+
49
+ if input_path.suffix != ".py":
50
+ parser.error(
51
+ f"input file must have a .py extension, got '{input_path.suffix}'"
52
+ )
53
+
54
+ if args.stdout:
55
+ print(transpile_file(str(input_path)))
56
+ else:
57
+ output_path = args.output or str(input_path.with_suffix(OUTPUT_EXTENSION))
58
+ transpile_file(str(input_path), output_path)
59
+ print(f"✓ Transpiled '{input_path}' → '{output_path}'")
@@ -0,0 +1,25 @@
1
+ {
2
+ "print": "打印",
3
+ "input": "输入",
4
+ "len": "长度",
5
+ "range": "范围",
6
+ "int": "整数",
7
+ "float": "浮点",
8
+ "str": "字符串",
9
+ "bool": "布尔",
10
+ "list": "列表",
11
+ "dict": "字典",
12
+ "set": "集合",
13
+ "tuple": "元组",
14
+ "type": "类型",
15
+ "open": "打开",
16
+ "enumerate": "枚举",
17
+ "zip": "压缩",
18
+ "map": "映射",
19
+ "filter": "过滤",
20
+ "sum": "求和",
21
+ "max": "最大",
22
+ "min": "最小",
23
+ "abs": "绝对值",
24
+ "sorted": "排序"
25
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "__name__": "__名称__",
3
+ "__main__": "__主程序__"
4
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "if": "如果",
3
+ "elif": "否则如果",
4
+ "else": "否则",
5
+ "for": "对于",
6
+ "while": "当",
7
+ "break": "中断",
8
+ "continue": "继续",
9
+ "pass": "跳过",
10
+ "return": "返回",
11
+ "def": "定义",
12
+ "class": "类",
13
+ "import": "导入",
14
+ "from": "从",
15
+ "as": "作为",
16
+ "try": "尝试",
17
+ "except": "异常",
18
+ "finally": "最后",
19
+ "raise": "抛出",
20
+ "with": "使用",
21
+ "lambda": "匿名函数",
22
+ "yield": "生成",
23
+ "global": "全局",
24
+ "nonlocal": "非局部",
25
+ "del": "删除",
26
+ "assert": "断言",
27
+ "is": "是",
28
+ "in": "于",
29
+ "not": "非",
30
+ "and": "且",
31
+ "or": "或",
32
+ "True": "真",
33
+ "False": "假",
34
+ "None": "空"
35
+ }
@@ -0,0 +1,14 @@
1
+ import json
2
+ from pathlib import Path
3
+
4
+ BASE = Path(__file__).parent / "data"
5
+
6
+
7
+ def load_json(name: str) -> dict:
8
+ with open(BASE / f"{name}.json", "r", encoding="utf-8") as f:
9
+ return json.load(f)
10
+
11
+
12
+ KEYWORDS = load_json("keywords")
13
+ BUILTINS = load_json("builtins")
14
+ CONSTANTS = load_json("constants")
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,55 @@
1
+ import io
2
+ import tokenize
3
+ from pathlib import Path
4
+
5
+ from .loader import KEYWORDS, BUILTINS, CONSTANTS
6
+
7
+
8
+ def build_translation_table(*tables: dict) -> dict:
9
+ """Merge translation tables, refusing to silently overwrite a key."""
10
+ merged: dict = {}
11
+ for table in tables:
12
+ overlap = merged.keys() & table.keys()
13
+ if overlap:
14
+ raise ValueError(f"Duplicate translation keys found: {overlap}")
15
+ merged.update(table)
16
+ return merged
17
+
18
+
19
+ TRANSLATIONS = build_translation_table(KEYWORDS, BUILTINS, CONSTANTS)
20
+
21
+
22
+ def transpile_source(source: str) -> str:
23
+ """
24
+ Translate Python source into Mandarin-keyword Python.
25
+
26
+ Only NAME tokens (keywords, builtins, and known constants) are
27
+ translated. Strings, comments, numbers, and operators are left
28
+ untouched, so this is safe for things like `print("print")`.
29
+
30
+ Note: this is a cosmetic transpiler. The output is not valid
31
+ Python and cannot be run directly by CPython. A reverse-translation
32
+ step (or a custom interpreter) would be needed to execute it.
33
+ """
34
+ tokens = []
35
+ readline = io.StringIO(source).readline
36
+
37
+ for tok in tokenize.generate_tokens(readline):
38
+ toktype, tokval, start, end, line = tok
39
+
40
+ if toktype == tokenize.NAME and tokval in TRANSLATIONS:
41
+ tokval = TRANSLATIONS[tokval]
42
+
43
+ tokens.append((toktype, tokval, start, end, line))
44
+
45
+ return tokenize.untokenize(tokens)
46
+
47
+
48
+ def transpile_file(input_file: str, output_file: str | None = None) -> str:
49
+ source = Path(input_file).read_text(encoding="utf-8")
50
+ result = transpile_source(source)
51
+
52
+ if output_file:
53
+ Path(output_file).write_text(result, encoding="utf-8")
54
+
55
+ return result
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,50 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="RedPanda-transpiler",
5
+ version="0.1.0",
6
+ description="A Python to Mandarin Chinese transpiler.",
7
+ long_description=open("README.md", encoding="utf-8").read(),
8
+ long_description_content_type="text/markdown",
9
+ author="fmasterpro27",
10
+ license="Apache-2.0",
11
+ python_requires=">=3.11",
12
+ packages=find_packages(),
13
+ include_package_data=True,
14
+ package_data={
15
+ "redpanda": ["data/**/*.json"],
16
+ },
17
+ install_requires=[],
18
+ entry_points={
19
+ "console_scripts": [
20
+ "redpanda=redpanda.cli:main",
21
+ ],
22
+ },
23
+ keywords=[
24
+ "python",
25
+ "transpiler",
26
+ "compiler",
27
+ "parser",
28
+ "mandarin",
29
+ "chinese",
30
+ "language",
31
+ "codegen",
32
+ "redpanda",
33
+ ],
34
+ classifiers=[
35
+ "Development Status :: 3 - Alpha",
36
+ "Intended Audience :: Developers",
37
+ "Topic :: Software Development :: Compilers",
38
+ "Topic :: Software Development :: Interpreters",
39
+ "Programming Language :: Python :: 3",
40
+ "Programming Language :: Python :: 3.11",
41
+ "Programming Language :: Python :: 3.12",
42
+ "Programming Language :: Python :: 3.13",
43
+ "Operating System :: OS Independent",
44
+ ],
45
+ project_urls={
46
+ "Homepage": "https://github.com/Fmasterpro27/RedPanda-transpiler",
47
+ "Repository": "https://github.com/Fmasterpro27/RedPanda-transpiler",
48
+ "Issues": "https://github.com/Fmasterpro27/RedPanda-transpiler/issues",
49
+ },
50
+ )
@@ -0,0 +1,21 @@
1
+ from redpanda import transpile_source
2
+
3
+
4
+ def test_print():
5
+ assert transpile_source("print('Hello')") == "打印('Hello')"
6
+
7
+
8
+ def test_if():
9
+ source = "if True:\n pass"
10
+ result = transpile_source(source)
11
+
12
+ assert "如果" in result
13
+ assert "真" in result
14
+ assert "跳过" in result
15
+
16
+
17
+ def test_strings_not_translated():
18
+ source = 'print("print if else")'
19
+ result = transpile_source(source)
20
+
21
+ assert '打印("print if else")' == result