multilingualprogramming 0.2.0__py3-none-any.whl
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.
- multilingualprogramming/__init__.py +74 -0
- multilingualprogramming/__main__.py +194 -0
- multilingualprogramming/codegen/__init__.py +12 -0
- multilingualprogramming/codegen/executor.py +215 -0
- multilingualprogramming/codegen/python_generator.py +592 -0
- multilingualprogramming/codegen/repl.py +489 -0
- multilingualprogramming/codegen/runtime_builtins.py +308 -0
- multilingualprogramming/core/__init__.py +12 -0
- multilingualprogramming/core/ir.py +29 -0
- multilingualprogramming/core/lowering.py +24 -0
- multilingualprogramming/datetime/__init__.py +11 -0
- multilingualprogramming/datetime/date_parser.py +190 -0
- multilingualprogramming/datetime/mp_date.py +210 -0
- multilingualprogramming/datetime/mp_datetime.py +153 -0
- multilingualprogramming/datetime/mp_time.py +147 -0
- multilingualprogramming/datetime/resource_loader.py +18 -0
- multilingualprogramming/exceptions.py +158 -0
- multilingualprogramming/imports.py +150 -0
- multilingualprogramming/keyword/__init__.py +13 -0
- multilingualprogramming/keyword/keyword_registry.py +249 -0
- multilingualprogramming/keyword/keyword_validator.py +59 -0
- multilingualprogramming/keyword/language_pack_validator.py +110 -0
- multilingualprogramming/lexer/__init__.py +11 -0
- multilingualprogramming/lexer/lexer.py +570 -0
- multilingualprogramming/lexer/source_reader.py +91 -0
- multilingualprogramming/lexer/token.py +54 -0
- multilingualprogramming/lexer/token_types.py +38 -0
- multilingualprogramming/numeral/__init__.py +11 -0
- multilingualprogramming/numeral/abstract_numeral.py +232 -0
- multilingualprogramming/numeral/complex_numeral.py +190 -0
- multilingualprogramming/numeral/fraction_numeral.py +165 -0
- multilingualprogramming/numeral/mp_numeral.py +243 -0
- multilingualprogramming/numeral/numeral_converter.py +151 -0
- multilingualprogramming/numeral/roman_numeral.py +301 -0
- multilingualprogramming/numeral/unicode_numeral.py +292 -0
- multilingualprogramming/parser/__init__.py +28 -0
- multilingualprogramming/parser/ast_nodes.py +459 -0
- multilingualprogramming/parser/ast_printer.py +677 -0
- multilingualprogramming/parser/error_messages.py +75 -0
- multilingualprogramming/parser/parser.py +1796 -0
- multilingualprogramming/parser/semantic_analyzer.py +689 -0
- multilingualprogramming/parser/surface_normalizer.py +282 -0
- multilingualprogramming/resources/datetime/eras.json +23 -0
- multilingualprogramming/resources/datetime/formats.json +32 -0
- multilingualprogramming/resources/datetime/months.json +150 -0
- multilingualprogramming/resources/datetime/weekdays.json +90 -0
- multilingualprogramming/resources/parser/error_messages.json +310 -0
- multilingualprogramming/resources/repl/commands.json +636 -0
- multilingualprogramming/resources/usm/builtins_aliases.json +731 -0
- multilingualprogramming/resources/usm/keywords.json +1063 -0
- multilingualprogramming/resources/usm/operators.json +532 -0
- multilingualprogramming/resources/usm/schema.json +34 -0
- multilingualprogramming/resources/usm/surface_patterns.json +1523 -0
- multilingualprogramming/unicode_string.py +140 -0
- multilingualprogramming/version.py +9 -0
- multilingualprogramming-0.2.0.dist-info/METADATA +350 -0
- multilingualprogramming-0.2.0.dist-info/RECORD +61 -0
- multilingualprogramming-0.2.0.dist-info/WHEEL +5 -0
- multilingualprogramming-0.2.0.dist-info/entry_points.txt +3 -0
- multilingualprogramming-0.2.0.dist-info/licenses/LICENSE +674 -0
- multilingualprogramming-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#
|
|
2
|
+
# SPDX-FileCopyrightText: 2022 John Samuel <johnsamuelwrites@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
"""Functions to represent numbers in multiple languages
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
import unicodedata
|
|
12
|
+
|
|
13
|
+
NUMBER_STRINGS = [
|
|
14
|
+
"ZERO",
|
|
15
|
+
"ONE",
|
|
16
|
+
"TWO",
|
|
17
|
+
"THREE",
|
|
18
|
+
"FOUR",
|
|
19
|
+
"FIVE",
|
|
20
|
+
"SIX",
|
|
21
|
+
"SEVEN",
|
|
22
|
+
"EIGHT",
|
|
23
|
+
"NINE",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
DIGIT_STRING = "DIGIT"
|
|
27
|
+
|
|
28
|
+
# Unicode vulgar fraction characters mapped to (numerator, denominator) tuples
|
|
29
|
+
UNICODE_FRACTION_MAP = {
|
|
30
|
+
"\u00bd": (1, 2), # ½
|
|
31
|
+
"\u2153": (1, 3), # ⅓
|
|
32
|
+
"\u2154": (2, 3), # ⅔
|
|
33
|
+
"\u00bc": (1, 4), # ¼
|
|
34
|
+
"\u00be": (3, 4), # ¾
|
|
35
|
+
"\u2155": (1, 5), # ⅕
|
|
36
|
+
"\u2156": (2, 5), # ⅖
|
|
37
|
+
"\u2157": (3, 5), # ⅗
|
|
38
|
+
"\u2158": (4, 5), # ⅘
|
|
39
|
+
"\u2159": (1, 6), # ⅙
|
|
40
|
+
"\u215a": (5, 6), # ⅚
|
|
41
|
+
"\u2150": (1, 7), # ⅐
|
|
42
|
+
"\u215b": (1, 8), # ⅛
|
|
43
|
+
"\u215c": (3, 8), # ⅜
|
|
44
|
+
"\u215d": (5, 8), # ⅝
|
|
45
|
+
"\u215e": (7, 8), # ⅞
|
|
46
|
+
"\u2151": (1, 9), # ⅑
|
|
47
|
+
"\u2152": (1, 10), # ⅒
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def get_number_list(language: str):
|
|
52
|
+
"""
|
|
53
|
+
get the unicode characters for the numbers in a given language
|
|
54
|
+
"""
|
|
55
|
+
number_list = []
|
|
56
|
+
lookup_language = language
|
|
57
|
+
if language != DIGIT_STRING:
|
|
58
|
+
lookup_language = language + " " + DIGIT_STRING
|
|
59
|
+
for number in NUMBER_STRINGS:
|
|
60
|
+
number = unicodedata.lookup(lookup_language + " " + number)
|
|
61
|
+
number_list.append(number)
|
|
62
|
+
return number_list
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def get_unicode_character(language: str, numstr: str):
|
|
66
|
+
"""
|
|
67
|
+
get the unicode characters for the numbers in a given language
|
|
68
|
+
"""
|
|
69
|
+
lookup_language = language
|
|
70
|
+
if language != DIGIT_STRING:
|
|
71
|
+
lookup_language = language + " " + DIGIT_STRING
|
|
72
|
+
character = unicodedata.lookup(lookup_language + " " + numstr)
|
|
73
|
+
return character
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def get_unicode_character_string(language: str, number: int):
|
|
77
|
+
"""
|
|
78
|
+
get the unicode characters for the numbers in a given language
|
|
79
|
+
"""
|
|
80
|
+
numstr = str(number)
|
|
81
|
+
lookup_language = language
|
|
82
|
+
if language != DIGIT_STRING:
|
|
83
|
+
lookup_language = language + " " + DIGIT_STRING
|
|
84
|
+
unicode_numstr = ""
|
|
85
|
+
for character in numstr:
|
|
86
|
+
if character == "-":
|
|
87
|
+
unicode_numstr = character
|
|
88
|
+
elif character == ".":
|
|
89
|
+
unicode_numstr = unicode_numstr + character
|
|
90
|
+
else:
|
|
91
|
+
unicode_character = unicodedata.lookup(
|
|
92
|
+
lookup_language + " " + NUMBER_STRINGS[int(character)]
|
|
93
|
+
)
|
|
94
|
+
unicode_numstr = unicode_numstr + unicode_character
|
|
95
|
+
return unicode_numstr
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def get_language_from_character(char):
|
|
99
|
+
"""
|
|
100
|
+
Detect the language name of a single Unicode digit character.
|
|
101
|
+
|
|
102
|
+
Parameters:
|
|
103
|
+
char (str): A single Unicode digit character
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
str | None: The language name (e.g., "MALAYALAM", "ARABIC-INDIC")
|
|
107
|
+
or None if not a decimal digit
|
|
108
|
+
"""
|
|
109
|
+
if unicodedata.category(char) != "Nd":
|
|
110
|
+
return None
|
|
111
|
+
char_name = unicodedata.name(char)
|
|
112
|
+
# Extract the language prefix (everything before " DIGIT ...")
|
|
113
|
+
language_name = re.sub(r" .*$", "", char_name)
|
|
114
|
+
return language_name
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def convert_numeral_string(numstr, source_language, target_language):
|
|
118
|
+
"""
|
|
119
|
+
Convert a numeral string from one script to another.
|
|
120
|
+
|
|
121
|
+
Parameters:
|
|
122
|
+
numstr (str): The numeral string to convert
|
|
123
|
+
source_language (str): Source language name (e.g., "MALAYALAM")
|
|
124
|
+
target_language (str): Target language name (e.g., "ARABIC-INDIC")
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
str: The numeral string in the target script
|
|
128
|
+
"""
|
|
129
|
+
source_digits = get_number_list(source_language)
|
|
130
|
+
target_digits = get_number_list(target_language)
|
|
131
|
+
digit_map = dict(zip(source_digits, target_digits))
|
|
132
|
+
|
|
133
|
+
result = ""
|
|
134
|
+
for char in numstr:
|
|
135
|
+
if char in digit_map:
|
|
136
|
+
result += digit_map[char]
|
|
137
|
+
else:
|
|
138
|
+
# Preserve non-digit characters (signs, separators)
|
|
139
|
+
result += char
|
|
140
|
+
return result
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: multilingualprogramming
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python application for multilingual programming
|
|
5
|
+
Author-email: John Samuel <johnsamuelwrites@example.com>
|
|
6
|
+
License: GPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/johnsamuelwrites/multilingual
|
|
8
|
+
Project-URL: Documentation, https://johnsamuelwrites.github.io/multilingual/
|
|
9
|
+
Project-URL: Repository, https://github.com/johnsamuelwrites/multilingual
|
|
10
|
+
Project-URL: Issues, https://github.com/johnsamuelwrites/multilingual/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/johnsamuelwrites/multilingual/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: programming-language,multilingual,compiler,transpiler,education
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: roman>=3.3
|
|
23
|
+
Requires-Dist: python-dateutil>=2.8
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
27
|
+
Requires-Dist: pylint; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# multilingual
|
|
31
|
+
Not yet another programming language. A multilingual one.
|
|
32
|
+
|
|
33
|
+
> **One programming model. Many human languages.**
|
|
34
|
+
> Write code in your language through multilingual frontends targeting one formal core.
|
|
35
|
+
|
|
36
|
+
## Motivation
|
|
37
|
+
|
|
38
|
+
- Problem: programming is still heavily bound to English-centric syntax and keywords.
|
|
39
|
+
- Idea: build multiple language frontends that compile into one typed core representation.
|
|
40
|
+
- Today: this is a small but working prototype; you can already write and run programs in English, French, Spanish, and other supported languages.
|
|
41
|
+
|
|
42
|
+
## Project Positioning
|
|
43
|
+
|
|
44
|
+
- This is not a beginner-only teaching DSL.
|
|
45
|
+
- This project targets a broad Python-like subset with localized language frontends.
|
|
46
|
+
- Goal: language-inclusive authoring without fragmenting runtime behavior.
|
|
47
|
+
|
|
48
|
+
## Who Is This For?
|
|
49
|
+
|
|
50
|
+
`multilingual` is for teachers, language enthusiasts, programming-language hobbyists, and people exploring LLM-assisted coding workflows across multiple human languages.
|
|
51
|
+
|
|
52
|
+
## Why Multilingual
|
|
53
|
+
|
|
54
|
+
- **Language-inclusive syntax**: Use localized keywords and built-in aliases (for example, `intervalle`, `rango`, `intervallo`).
|
|
55
|
+
- **Single execution pipeline**: Same flow for every language: lexer -> parser -> core lowering -> semantic checks -> Python codegen -> runtime.
|
|
56
|
+
- **Data-driven extensibility**: Add languages by updating registries/resources, not by rewriting parser/codegen logic.
|
|
57
|
+
- **REPL-first experience**: Start quickly, switch languages live, inspect keywords/operators from inside REPL.
|
|
58
|
+
|
|
59
|
+
### Pipeline Illustration
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
## What This Is / Is Not
|
|
64
|
+
|
|
65
|
+
- `Is`: a multilingual frontend family over one formal core.
|
|
66
|
+
- `Is`: a research/prototyping platform for localization-aware language tooling.
|
|
67
|
+
- `Is`: a forward-compilation model (`surface -> core -> execution`) with no round-trip guarantee.
|
|
68
|
+
- `Is not`: a claim that syntax translation alone solves all onboarding barriers.
|
|
69
|
+
- `Is not`: full natural-language understanding.
|
|
70
|
+
- `Is not`: a replacement for English-heavy ecosystem docs, examples, and tooling (yet).
|
|
71
|
+
|
|
72
|
+
## Current Limitations
|
|
73
|
+
|
|
74
|
+
- Localized keywords can still feel unnatural in some languages because grammar/word order is mostly shared.
|
|
75
|
+
- A small declarative surface-normalization layer now supports selected alternate phrasing patterns, but coverage is still limited.
|
|
76
|
+
- The project supports a controlled subset (CNL-style) per language, not unconstrained natural language.
|
|
77
|
+
- Standard library/module APIs mostly stay canonical Python names; localization is focused on keywords and selected builtins.
|
|
78
|
+
- Full drop-in compatibility with arbitrary existing Python code is not claimed yet.
|
|
79
|
+
|
|
80
|
+
Details:
|
|
81
|
+
- Word order and naturalness: [docs/word_order_and_naturalness.md](docs/word_order_and_naturalness.md)
|
|
82
|
+
- Stdlib localization boundaries: [docs/stdlib_localization.md](docs/stdlib_localization.md)
|
|
83
|
+
- Controlled language scope: [docs/cnl_scope.md](docs/cnl_scope.md)
|
|
84
|
+
- Python compatibility matrix: [docs/compatibility_matrix.md](docs/compatibility_matrix.md)
|
|
85
|
+
- Python 3.12 compatibility roadmap: [docs/compatibility_roadmap.md](docs/compatibility_roadmap.md)
|
|
86
|
+
|
|
87
|
+
## Quick Start
|
|
88
|
+
|
|
89
|
+
Source files for this language use the `.ml` extension (for example: `hello.ml`).
|
|
90
|
+
Requires Python 3.12 or newer.
|
|
91
|
+
|
|
92
|
+
### 1. Install
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install -r requirements.txt
|
|
96
|
+
# or
|
|
97
|
+
pip install .
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 2. Hello World In Multiple Languages
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
# English
|
|
104
|
+
print("Hello world")
|
|
105
|
+
|
|
106
|
+
# French
|
|
107
|
+
afficher("Bonjour le monde")
|
|
108
|
+
|
|
109
|
+
# Spanish (another language example)
|
|
110
|
+
imprimir("Hola mundo")
|
|
111
|
+
|
|
112
|
+
# Japanese
|
|
113
|
+
表示("こんにちは世界")
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 3. Use the REPL (interactive mode)
|
|
118
|
+
|
|
119
|
+
Start REPL:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# 1) Default mode (English keywords)
|
|
123
|
+
multilingual repl
|
|
124
|
+
|
|
125
|
+
# 2) French mode
|
|
126
|
+
multilingual repl --lang fr
|
|
127
|
+
|
|
128
|
+
# Optional: show generated Python while executing
|
|
129
|
+
multilingual repl --show-python
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Inside the REPL, type code and press Enter to execute.
|
|
133
|
+
|
|
134
|
+
Default mode example (English):
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
>>> let total = 0
|
|
138
|
+
>>> for i in range(4):
|
|
139
|
+
... total = total + i
|
|
140
|
+
...
|
|
141
|
+
>>> print(total)
|
|
142
|
+
6
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
French mode example:
|
|
146
|
+
|
|
147
|
+
```text
|
|
148
|
+
>>> soit somme = 0
|
|
149
|
+
>>> pour i dans intervalle(4):
|
|
150
|
+
... somme = somme + i
|
|
151
|
+
...
|
|
152
|
+
>>> afficher(somme)
|
|
153
|
+
6
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
French phrase aliases are also supported:
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
si x:
|
|
160
|
+
afficher("ok")
|
|
161
|
+
sinon si y:
|
|
162
|
+
afficher("fallback")
|
|
163
|
+
|
|
164
|
+
pour chaque i dans intervalle(3):
|
|
165
|
+
afficher(i)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
REPL commands:
|
|
169
|
+
|
|
170
|
+
- `:help` show commands
|
|
171
|
+
- `:language <code>` switch language
|
|
172
|
+
- `:python` toggle generated Python display
|
|
173
|
+
- `:reset` clear session state
|
|
174
|
+
- `:kw [XX]` show language keywords
|
|
175
|
+
- `:ops [XX]` show operators and symbols
|
|
176
|
+
- `:q` exit
|
|
177
|
+
|
|
178
|
+
Note: selected universal built-ins (for example `range`, `len`, `sum`) support localized aliases while keeping the universal names available.
|
|
179
|
+
|
|
180
|
+
### 4. Execute and inspect programs
|
|
181
|
+
|
|
182
|
+
Execution/transpilation examples and AST parsing examples are in [USAGE.md](USAGE.md).
|
|
183
|
+
|
|
184
|
+
### 5. Run A `.ml` Source File
|
|
185
|
+
|
|
186
|
+
Create a file, for example `hello.ml`:
|
|
187
|
+
|
|
188
|
+
```text
|
|
189
|
+
print("Hello world")
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Run it:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
multilingual run hello.ml
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Optional (force language instead of auto-detect):
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
multilingual run hello.ml --lang fr
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 6. Cross-Language Module Imports
|
|
205
|
+
|
|
206
|
+
You can import `.ml` modules across languages in one program. Example:
|
|
207
|
+
|
|
208
|
+
`module_fr.ml`:
|
|
209
|
+
|
|
210
|
+
```text
|
|
211
|
+
soit valeur = 41
|
|
212
|
+
def incremente(x):
|
|
213
|
+
retour x + 1
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
`main_en.ml`:
|
|
217
|
+
|
|
218
|
+
```text
|
|
219
|
+
import module_fr
|
|
220
|
+
print(module_fr.incremente(module_fr.valeur))
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Run:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
multilingual run main_en.ml --lang en
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Roadmap (Short)
|
|
230
|
+
|
|
231
|
+
- v0 (today): toy-but-working interpreter/transpiler, multiple languages, core constructs, REPL, and a tested end-to-end pipeline.
|
|
232
|
+
- next: better tooling, IDE support, more languages, stronger frontend equivalence tests, and potential LLM-assisted code translation workflows.
|
|
233
|
+
|
|
234
|
+
## What You Can Use
|
|
235
|
+
|
|
236
|
+
- Numerals across scripts: `MPNumeral`, `UnicodeNumeral`, `RomanNumeral`
|
|
237
|
+
- Extended numerals: `ComplexNumeral`, `FractionNumeral`, `NumeralConverter`
|
|
238
|
+
- Keyword model: `KeywordRegistry`, `KeywordValidator`
|
|
239
|
+
- Date/time: `MPDate`, `MPTime`, `MPDatetime`
|
|
240
|
+
- Frontend: `Lexer`, `Parser`, AST nodes, `SemanticAnalyzer`
|
|
241
|
+
- Runtime: `PythonCodeGenerator`, `RuntimeBuiltins`, `ProgramExecutor`, `REPL`
|
|
242
|
+
|
|
243
|
+
Additional syntax now supported:
|
|
244
|
+
|
|
245
|
+
- Type annotations (`x: int`, `def f(x: int) -> str`)
|
|
246
|
+
- Nested comprehension clauses (`[x for row in rows for x in row]`)
|
|
247
|
+
- Set literals (`{1, 2, 3}`)
|
|
248
|
+
- Multiple context managers (`with A() as a, B() as b`)
|
|
249
|
+
- Dictionary unpacking (`{**d1, **d2}`)
|
|
250
|
+
- Hex/oct/bin literals (`0xFF`, `0o77`, `0b101`)
|
|
251
|
+
- Scientific notation (`1.5e-3`)
|
|
252
|
+
- Async features (`async def`, `await`, `async for`, `async with`)
|
|
253
|
+
- Walrus operator (`:=`)
|
|
254
|
+
|
|
255
|
+
Supported pilot languages: English, French, Spanish, German, Italian, Portuguese, Polish, Dutch, Swedish, Danish, Finnish, Hindi, Arabic, Bengali, Tamil, Chinese (Simplified), Japanese.
|
|
256
|
+
|
|
257
|
+
## Run Examples
|
|
258
|
+
|
|
259
|
+
See [examples/README.md](examples/README.md) for narrative `.ml` examples
|
|
260
|
+
(English/French equivalents) and runnable commands.
|
|
261
|
+
|
|
262
|
+
### Japanese Surface Syntax Example
|
|
263
|
+
|
|
264
|
+
These two files compute the same result (`15`) using canonical and alternate
|
|
265
|
+
surface loop phrasing:
|
|
266
|
+
|
|
267
|
+
- Surface form: `examples/surface_for_ja.ml`
|
|
268
|
+
- Canonical form: `examples/surface_for_ja_canonical.ml`
|
|
269
|
+
|
|
270
|
+
Run:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
multilingual run examples/surface_for_ja.ml --lang ja
|
|
274
|
+
multilingual run examples/surface_for_ja_canonical.ml --lang ja
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Spanish And Portuguese Surface Syntax Examples
|
|
278
|
+
|
|
279
|
+
These pairs compute the same result using canonical and iterable-first loop phrasing:
|
|
280
|
+
|
|
281
|
+
- Spanish surface: `examples/surface_for_es.ml`
|
|
282
|
+
- Spanish canonical: `examples/surface_for_es_canonical.ml`
|
|
283
|
+
- Portuguese surface: `examples/surface_for_pt.ml`
|
|
284
|
+
- Portuguese canonical: `examples/surface_for_pt_canonical.ml`
|
|
285
|
+
|
|
286
|
+
Run:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
multilingual run examples/surface_for_es.ml --lang es
|
|
290
|
+
multilingual run examples/surface_for_es_canonical.ml --lang es
|
|
291
|
+
multilingual run examples/surface_for_pt.ml --lang pt
|
|
292
|
+
multilingual run examples/surface_for_pt_canonical.ml --lang pt
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Semantic Equivalence (English vs French)
|
|
296
|
+
|
|
297
|
+
These two snippets are semantically equivalent:
|
|
298
|
+
|
|
299
|
+
English (`examples/arithmetics_en.ml`):
|
|
300
|
+
|
|
301
|
+
```text
|
|
302
|
+
let a = 10
|
|
303
|
+
let b = 3
|
|
304
|
+
print("a + b =", a + b)
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
French (`examples/arithmetics_fr.ml`):
|
|
308
|
+
|
|
309
|
+
```text
|
|
310
|
+
soit a = 10
|
|
311
|
+
soit b = 3
|
|
312
|
+
afficher("a + b =", a + b)
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## Documentation
|
|
316
|
+
|
|
317
|
+
Use this README for setup and workflow; use `docs/` for design rationale and policy details.
|
|
318
|
+
|
|
319
|
+
- Usage guide: [USAGE.md](USAGE.md)
|
|
320
|
+
- Examples guide: [examples/README.md](examples/README.md)
|
|
321
|
+
- Detailed reference: [docs/reference.md](docs/reference.md)
|
|
322
|
+
- Design overview: [docs/design.md](docs/design.md)
|
|
323
|
+
- Related work and differentiation: [docs/related_work.md](docs/related_work.md)
|
|
324
|
+
- Core formalization: [docs/core_spec.md](docs/core_spec.md)
|
|
325
|
+
- Frontend translation contracts: [docs/frontend_contracts.md](docs/frontend_contracts.md)
|
|
326
|
+
- Evaluation plan: [docs/evaluation_plan.md](docs/evaluation_plan.md)
|
|
327
|
+
- Word order and syntax naturalness notes: [docs/word_order_and_naturalness.md](docs/word_order_and_naturalness.md)
|
|
328
|
+
- Standard library localization strategy: [docs/stdlib_localization.md](docs/stdlib_localization.md)
|
|
329
|
+
- Controlled language scope and ambiguity policy: [docs/cnl_scope.md](docs/cnl_scope.md)
|
|
330
|
+
- Python compatibility matrix: [docs/compatibility_matrix.md](docs/compatibility_matrix.md)
|
|
331
|
+
- Python 3.12 compatibility roadmap: [docs/compatibility_roadmap.md](docs/compatibility_roadmap.md)
|
|
332
|
+
- Translation governance guide: [docs/translation_guidelines.md](docs/translation_guidelines.md)
|
|
333
|
+
- Development and debugging guide: [docs/development.md](docs/development.md)
|
|
334
|
+
- Guide complet en francais: [docs/fr/programmation.md](docs/fr/programmation.md)
|
|
335
|
+
- Language onboarding guide: [docs/language_onboarding.md](docs/language_onboarding.md)
|
|
336
|
+
- Contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
337
|
+
- Release process: [docs/releasing.md](docs/releasing.md)
|
|
338
|
+
- Changelog: [CHANGELOG.md](CHANGELOG.md)
|
|
339
|
+
|
|
340
|
+
## Development
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
python -m pytest -q
|
|
344
|
+
python -m pylint $(git ls-files '*.py')
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## License
|
|
348
|
+
|
|
349
|
+
- Code: GPLv3+
|
|
350
|
+
- Documentation/content: CC BY-SA 4.0
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
multilingualprogramming/__init__.py,sha256=kZaEMB-EdIKtSiYskrHtI4ZxGHuk5-2uhNfT8x9yDu8,2772
|
|
2
|
+
multilingualprogramming/__main__.py,sha256=3zXVL1gMiljV7GEdPUxXs2YYKZaIbiNjz_OMKebbuBs,5824
|
|
3
|
+
multilingualprogramming/exceptions.py,sha256=lr_AIrG-_82bFb6X85edbdUfaDX7EaQIm8Uamdd8vvk,4020
|
|
4
|
+
multilingualprogramming/imports.py,sha256=2qTrQqtWAcmCU7uFI8vQYieqwzttEOJShtjnjZQ2u-4,5354
|
|
5
|
+
multilingualprogramming/unicode_string.py,sha256=cjVu8dOFZfTgu23oNEfcsGCebyQA5fDfd6m6HVEP6ZA,3943
|
|
6
|
+
multilingualprogramming/version.py,sha256=DfJZ14J5pP0gfQYuFafLqGj-Q9cORzCO4DJHASHGll8,224
|
|
7
|
+
multilingualprogramming/codegen/__init__.py,sha256=Kl9GXlj55k-a9_eDbOuKOWyGlnGLvB3yraUSSSIAA-M,510
|
|
8
|
+
multilingualprogramming/codegen/executor.py,sha256=_v4S61uFSvHyXUZ2r7cMMQDUHKeCeoULb7zKV7UMYAU,7487
|
|
9
|
+
multilingualprogramming/codegen/python_generator.py,sha256=BHOU0fATQsQrXQMKADT8dR4YBd4xcDxLi_pQ1lNVWAs,20043
|
|
10
|
+
multilingualprogramming/codegen/repl.py,sha256=5zuJciBZ9XaUVpu6H7oFS0WrPzNECpj6CQSxRhHvs2Y,16949
|
|
11
|
+
multilingualprogramming/codegen/runtime_builtins.py,sha256=22z4daH3htgidGOc7adQbKS0MvepRv1qATj20SDDnCE,10554
|
|
12
|
+
multilingualprogramming/core/__init__.py,sha256=z4O7jBv6D0VW08wKBj2Kpi2rk2U9vrIJy8GR5fZ-ggU,368
|
|
13
|
+
multilingualprogramming/core/ir.py,sha256=WH6ZWkqxRFWMFrsLk-zRQ2O0Jx0bQz1-txMsukPu3WU,956
|
|
14
|
+
multilingualprogramming/core/lowering.py,sha256=9uzCVZF59tWAZjEb1iAP8h6rHAKN0GujD1ujRhtYWeQ,783
|
|
15
|
+
multilingualprogramming/datetime/__init__.py,sha256=GBo8lhOi72rfpbLZSQgGkrjyCJYW8PBteT4zZXhfC_s,368
|
|
16
|
+
multilingualprogramming/datetime/date_parser.py,sha256=anLszt8HAji4B_dzEey15pW7qldQ4F2JBQIxiMxc1Go,6140
|
|
17
|
+
multilingualprogramming/datetime/mp_date.py,sha256=_hwG3lzOh3CRggJqRJb7x5fZ2V08I9H9zDmk4UHxz8s,6369
|
|
18
|
+
multilingualprogramming/datetime/mp_datetime.py,sha256=z78YQYjsIfknrOQ73t9TYKYvpAoIIT7-2NHTO7uhaxY,4489
|
|
19
|
+
multilingualprogramming/datetime/mp_time.py,sha256=7jU-YGSgSRBHTgsMgYzXGNETAPrdoYyQYPUaWq0mEvg,4313
|
|
20
|
+
multilingualprogramming/datetime/resource_loader.py,sha256=JrH7McRzNjUQfv-EKh6T9EqQZiZYUsCV70TQ47jAVMQ,553
|
|
21
|
+
multilingualprogramming/keyword/__init__.py,sha256=zNmDE0vVSPkGm237sVQoywF26r0yxI1ZK-C4B8FkgMU,434
|
|
22
|
+
multilingualprogramming/keyword/keyword_registry.py,sha256=ha4Uzd9g5bT0rh-1jfe1NxTzFc8nJhNryE36RVqBR-Q,8400
|
|
23
|
+
multilingualprogramming/keyword/keyword_validator.py,sha256=8iRvSo1YBv_3OVSAHIjTt6vAAKirkms0ImLvxeRIKIE,1810
|
|
24
|
+
multilingualprogramming/keyword/language_pack_validator.py,sha256=Z1s3Gb_1JveM4lLVXPPzUKAFU3sJjJPDYC_IcfDmow4,4126
|
|
25
|
+
multilingualprogramming/lexer/__init__.py,sha256=Kvd2NCNSx-x34qi3qKekQ87o_-k8ArGe7Glh1gwXoUE,349
|
|
26
|
+
multilingualprogramming/lexer/lexer.py,sha256=BoXENF0sMXNpQTWnUaiBZvs14FOtiaYY5anUxog9YrQ,23061
|
|
27
|
+
multilingualprogramming/lexer/source_reader.py,sha256=sxKFvb1MbBhCwRCF4_7pjzvewJahb39bjIc3DPCxMoM,2187
|
|
28
|
+
multilingualprogramming/lexer/token.py,sha256=hALWgGZ70DFUN9WvlWigJx4ZjUJ_e-XBBeSE9FegRoo,1705
|
|
29
|
+
multilingualprogramming/lexer/token_types.py,sha256=F6JbhfBvfF1ocpiXeW85vguUuSIW0PpSrn7lXN-6bhk,714
|
|
30
|
+
multilingualprogramming/numeral/__init__.py,sha256=sh8DOChxY6ZHquGOIDYUe_08ncqBcdw05XW_eFErjOA,390
|
|
31
|
+
multilingualprogramming/numeral/abstract_numeral.py,sha256=DRJl-H0xek2QafG1wO6a3V_DjYv6s1Atp7f_0xZ8Qt0,5064
|
|
32
|
+
multilingualprogramming/numeral/complex_numeral.py,sha256=I-ebYNGUQPP_HqSSEtGLF506zgpmdh8EHjBZ1zA6w7c,6633
|
|
33
|
+
multilingualprogramming/numeral/fraction_numeral.py,sha256=xhHALAKwD84YKpPHO2hHdHwKYb0XzLFwW8fwaFjqMVE,5218
|
|
34
|
+
multilingualprogramming/numeral/mp_numeral.py,sha256=yPCWKDeNlINRl5ErYKv24p1RhhdVRkDpzy1XipaJSso,7050
|
|
35
|
+
multilingualprogramming/numeral/numeral_converter.py,sha256=MYtZWnctQJC6TYLQo-5V3LYbCV5FsALtY59J94ZHf9g,4610
|
|
36
|
+
multilingualprogramming/numeral/roman_numeral.py,sha256=B9Y4E1att8WgvGWSRPY1KNbn7kW66eUjKPN62JUlP5I,8216
|
|
37
|
+
multilingualprogramming/numeral/unicode_numeral.py,sha256=O54kufd_6Ti4Hz0qrx1gUWgXEtOKkN9p4MTguvspByc,8385
|
|
38
|
+
multilingualprogramming/parser/__init__.py,sha256=BaLsj6q_c1Vfc5f6hJLy__bQeZ3Bw0IS87lSxuai06A,1281
|
|
39
|
+
multilingualprogramming/parser/ast_nodes.py,sha256=VPhry_SE-oBWOtXZNMpo6dK88hvN7v21xZVFQc41KoE,18740
|
|
40
|
+
multilingualprogramming/parser/ast_printer.py,sha256=2ghfG-oW-DzMIbrV-lrl_qZKcWDImEuZybchVCrvdMU,19579
|
|
41
|
+
multilingualprogramming/parser/error_messages.py,sha256=UJP0TAthelH6q7xMNJHvik1vDdTGUGtVZ3kM-Jyo_2w,2065
|
|
42
|
+
multilingualprogramming/parser/parser.py,sha256=C2xgX8ExXyP0e5uuG_yJjrMofzNSlahlMMEpg1rMPmc,69210
|
|
43
|
+
multilingualprogramming/parser/semantic_analyzer.py,sha256=4pFYZDwTw3tjDRogrBBIGqwa80S2uDHkiFRwBfswAUk,23709
|
|
44
|
+
multilingualprogramming/parser/surface_normalizer.py,sha256=H9qAjuyMmA69h-G8rKcSps0ka7qIXrN33c1eL0cfIDc,10676
|
|
45
|
+
multilingualprogramming/resources/datetime/eras.json,sha256=PeTwws34qfLvXsD3zmbSl3soixvGMPswktv928SRcTE,924
|
|
46
|
+
multilingualprogramming/resources/datetime/formats.json,sha256=5NkEjFyQA34NdntbhBtiHP8AzIkcGK4Ql6dtMrxZz6s,1796
|
|
47
|
+
multilingualprogramming/resources/datetime/months.json,sha256=IRbFilDCiD-K6mIPBKQJI90IzmQldGlQ-rbSvvKjmfw,6826
|
|
48
|
+
multilingualprogramming/resources/datetime/weekdays.json,sha256=C42Uj5DFS2uzajsv2YotExGAoFhQ2rb4hpPAc9vr9iA,4162
|
|
49
|
+
multilingualprogramming/resources/parser/error_messages.json,sha256=ia3MJWtFOBjTwb15vPz1rommo9IYS2E0rPetfdjiTMw,18227
|
|
50
|
+
multilingualprogramming/resources/repl/commands.json,sha256=Hvf-09G-QaifCzx6ok31fXozftXqDNA4yBct5MsjUkA,17546
|
|
51
|
+
multilingualprogramming/resources/usm/builtins_aliases.json,sha256=2BbZ8cmlr7LnfBVManJdaaLPAkepAQRJv5hqqOLTghA,20738
|
|
52
|
+
multilingualprogramming/resources/usm/keywords.json,sha256=giNsJBm36dloAD1ZHuBMmWWhQTcmRUxLLSYnndHrzEA,24816
|
|
53
|
+
multilingualprogramming/resources/usm/operators.json,sha256=2mlKGzCLKJOl2wHRlN99IXaEq_Biam-P6tyi6nEQrCY,10174
|
|
54
|
+
multilingualprogramming/resources/usm/schema.json,sha256=sfME6kT8XwAc8_TPX6qcjilbdZtul9sMqOrVMqCsT5Q,921
|
|
55
|
+
multilingualprogramming/resources/usm/surface_patterns.json,sha256=RIPys1hvMbbhKlcfOI0-92115oJXggXqLUrfSxm51b0,30536
|
|
56
|
+
multilingualprogramming-0.2.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
57
|
+
multilingualprogramming-0.2.0.dist-info/METADATA,sha256=xWo0ozrXwqLXImV-98FH40pCEiOLUcyw2n6-aflR6aw,11350
|
|
58
|
+
multilingualprogramming-0.2.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
|
|
59
|
+
multilingualprogramming-0.2.0.dist-info/entry_points.txt,sha256=8P_6PludYfdyeKtxMQTDcOUEX3owTxy6CBEZM3liamU,119
|
|
60
|
+
multilingualprogramming-0.2.0.dist-info/top_level.txt,sha256=Rn6mGpyFxqtwWDxQ0Su_PNCL8JmsqdAIc24mSlOZEWE,24
|
|
61
|
+
multilingualprogramming-0.2.0.dist-info/RECORD,,
|