Yapton 0.1.2__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.
- yapton-0.1.2/LICENSE +21 -0
- yapton-0.1.2/PKG-INFO +168 -0
- yapton-0.1.2/README.md +159 -0
- yapton-0.1.2/pyproject.toml +19 -0
- yapton-0.1.2/setup.cfg +4 -0
- yapton-0.1.2/src/Yapton.egg-info/PKG-INFO +168 -0
- yapton-0.1.2/src/Yapton.egg-info/SOURCES.txt +15 -0
- yapton-0.1.2/src/Yapton.egg-info/dependency_links.txt +1 -0
- yapton-0.1.2/src/Yapton.egg-info/entry_points.txt +2 -0
- yapton-0.1.2/src/Yapton.egg-info/top_level.txt +1 -0
- yapton-0.1.2/src/yapton/__init__.py +111 -0
- yapton-0.1.2/src/yapton/cli.py +25 -0
yapton-0.1.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zahi Najmal
|
|
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.
|
yapton-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Yapton
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Yapton is an fun Python library that helps kids learn how to code Python using fun slang-keywords
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Dynamic: license-file
|
|
9
|
+
|
|
10
|
+
# Yapton
|
|
11
|
+
|
|
12
|
+
**Yapton is a small educational programming language that lets learners write Python-style programs with a few slang-inspired keywords.** A Yapton file (`.yap`) is translated to Python in memory and then run with the normal Python runtime. It is intended as a friendly bridge to Python, not as a replacement for it.
|
|
13
|
+
|
|
14
|
+
## What this project does
|
|
15
|
+
|
|
16
|
+
Yapton keeps ordinary Python syntax, data types, loops, expressions, and standard-library imports. It adds the following alternative words:
|
|
17
|
+
|
|
18
|
+
| Yapton | Python meaning |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| `yap(...)` | `print(...)` |
|
|
21
|
+
| `spill(...)` | `input(...)`, converting number-looking input to `int` or `float` |
|
|
22
|
+
| `vibe name():` | `def name():` |
|
|
23
|
+
| `fanumtax math` | `import math` |
|
|
24
|
+
| `optionC` | `elif` |
|
|
25
|
+
| `otherwise` | `else` |
|
|
26
|
+
| `W` / `L` | `True` / `False` |
|
|
27
|
+
|
|
28
|
+
For example:
|
|
29
|
+
|
|
30
|
+
```yap
|
|
31
|
+
fanumtax math
|
|
32
|
+
|
|
33
|
+
vibe greet(name):
|
|
34
|
+
yap("Welcome,", name)
|
|
35
|
+
|
|
36
|
+
name = spill("What is your name? ")
|
|
37
|
+
greet(name)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Project roles
|
|
41
|
+
|
|
42
|
+
The codebase has three clear responsibilities:
|
|
43
|
+
|
|
44
|
+
| Part | Role |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `src/yapton/__init__.py` | The **Yapton language engine**. It translates Yapton keywords into Python tokens, provides `spill`, runs `.yap` files, and prints the slang reference. |
|
|
47
|
+
| `src/yapton/cli.py` | The **command-line interface**. It accepts `yap program.yap` and `yap --slang-help`, then calls the language engine. |
|
|
48
|
+
| `pyproject.toml` | The **package configuration**. It declares the Python requirement and installs the `yap` command. |
|
|
49
|
+
| `sample1.yap` to `sample7.yap` | **Example Yapton programs**, ordered from small language demonstrations to larger projects. |
|
|
50
|
+
| `yap.bat` | The **Windows launcher**. It runs `python -m yapton.cli`, so it never depends on a copied, moved, or stale virtual environment. |
|
|
51
|
+
|
|
52
|
+
## Requirements
|
|
53
|
+
|
|
54
|
+
- Python 3.10 or newer
|
|
55
|
+
- PowerShell, Command Prompt, or another terminal
|
|
56
|
+
- Git, only if you want to publish the project on GitHub
|
|
57
|
+
|
|
58
|
+
Check that Python is available:
|
|
59
|
+
|
|
60
|
+
```powershell
|
|
61
|
+
py --version
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If `py` is not found, install Python from [python.org](https://www.python.org/downloads/) and make sure the installer option to add Python to PATH is enabled.
|
|
65
|
+
|
|
66
|
+
## Run it locally (Windows / PowerShell)
|
|
67
|
+
|
|
68
|
+
Open PowerShell in this project folder, then create a fresh virtual environment and install Yapton in editable mode:
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
cd "C:\path\to\Yapton"
|
|
72
|
+
py -m venv .venv
|
|
73
|
+
.\.venv\Scripts\Activate.ps1
|
|
74
|
+
python -m pip install --upgrade pip
|
|
75
|
+
python -m pip install -e .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Run an example:
|
|
79
|
+
|
|
80
|
+
```powershell
|
|
81
|
+
yap sample2.yap
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or run the larger example:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
yap sample5.yap
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
See the built-in language reference at any time:
|
|
91
|
+
|
|
92
|
+
```powershell
|
|
93
|
+
yap --slang-help
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### If PowerShell blocks activation
|
|
97
|
+
|
|
98
|
+
Activation is optional. Use the environment's Python directly instead:
|
|
99
|
+
|
|
100
|
+
```powershell
|
|
101
|
+
.\.venv\Scripts\python.exe -m pip install -e .
|
|
102
|
+
.\.venv\Scripts\yap.exe sample2.yap
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Run a new program
|
|
106
|
+
|
|
107
|
+
1. Create a file ending in `.yap`, such as `hello.yap`.
|
|
108
|
+
2. Add Yapton/Python code.
|
|
109
|
+
3. Run `yap hello.yap` while the environment is active.
|
|
110
|
+
|
|
111
|
+
Indentation and colons work exactly like Python. Regular Python can be mixed with the Yapton keywords shown above.
|
|
112
|
+
|
|
113
|
+
### Sample guide
|
|
114
|
+
|
|
115
|
+
| File | Demonstrates |
|
|
116
|
+
| --- | --- |
|
|
117
|
+
| `sample1.yap` | Functions, loops, lists, conditions, and Yapton booleans. |
|
|
118
|
+
| `sample2.yap` | Adding two numbers entered by the user. |
|
|
119
|
+
| `sample3.yap` | Subtracting two numbers entered by the user. |
|
|
120
|
+
| `sample4.yap` | Checking whether a number is positive or negative. |
|
|
121
|
+
| `sample5.yap` | A menu-driven student score tracker using Yapton imports. |
|
|
122
|
+
| `sample6.yap` | The same student tracker, showing that regular Python `import` also works. |
|
|
123
|
+
| `sample7.yap` | A first-person 3D maze. Install its extra dependency first with `python -m pip install ursina`. |
|
|
124
|
+
|
|
125
|
+
### Why `yap` works reliably in this folder
|
|
126
|
+
|
|
127
|
+
Windows chooses `yap.bat` in the current folder before an installed `yap` command. This project launcher deliberately uses `python -m yapton.cli` instead of a hard-coded path to `venv\\Scripts\\python.exe`. That means it uses the same Python installation that installed Yapton and will not break merely because a virtual-environment folder was moved, deleted, or created on another computer.
|
|
128
|
+
|
|
129
|
+
## Put it on GitHub
|
|
130
|
+
|
|
131
|
+
1. Sign in to [GitHub](https://github.com/) and select **New repository**.
|
|
132
|
+
2. Name it `Yapton`, choose Public or Private, and **do not** initialize it with a README, `.gitignore`, or license—the project already has the first two.
|
|
133
|
+
3. In PowerShell, from this project folder, run the following. Replace `YOUR-USERNAME` with your GitHub username:
|
|
134
|
+
|
|
135
|
+
```powershell
|
|
136
|
+
cd "C:\path\to\Yapton"
|
|
137
|
+
git init
|
|
138
|
+
git add .
|
|
139
|
+
git commit -m "Initial commit: Yapton language"
|
|
140
|
+
git branch -M main
|
|
141
|
+
git remote add origin https://github.com/YOUR-USERNAME/Yapton.git
|
|
142
|
+
git push -u origin main
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
GitHub may ask you to sign in or create a personal access token when you push over HTTPS. If Git reports that a remote called `origin` already exists, update it instead:
|
|
146
|
+
|
|
147
|
+
```powershell
|
|
148
|
+
git remote set-url origin https://github.com/YOUR-USERNAME/Yapton.git
|
|
149
|
+
git push -u origin main
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The included `.gitignore` prevents virtual environments, cache files, and build outputs from being uploaded. Do not upload `.venv/` or `venv/`; each contributor should create their own using the local setup steps above.
|
|
153
|
+
|
|
154
|
+
### Privacy check before publishing
|
|
155
|
+
|
|
156
|
+
The publishable source files contain no personal names, email addresses, passwords, API keys, or local computer paths. The ignored `venv/` folder is machine-specific and must not be uploaded. The `.gitignore` also excludes virtual environments and `.env` files, which are common places for private settings. Before each push, review exactly what will be uploaded with:
|
|
157
|
+
|
|
158
|
+
```powershell
|
|
159
|
+
git status
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Contributing
|
|
163
|
+
|
|
164
|
+
When adding a slang keyword, update both `NAME_MAP` and `print_slang_help()` in `src/yapton/__init__.py`, then add or update a `.yap` example that demonstrates it. Before committing, run an example and `yap --slang-help` to confirm the command still works.
|
|
165
|
+
|
|
166
|
+
## Current status
|
|
167
|
+
|
|
168
|
+
Yapton is an early educational prototype. Because programs ultimately execute as Python, only run `.yap` files you trust.
|
yapton-0.1.2/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Yapton
|
|
2
|
+
|
|
3
|
+
**Yapton is a small educational programming language that lets learners write Python-style programs with a few slang-inspired keywords.** A Yapton file (`.yap`) is translated to Python in memory and then run with the normal Python runtime. It is intended as a friendly bridge to Python, not as a replacement for it.
|
|
4
|
+
|
|
5
|
+
## What this project does
|
|
6
|
+
|
|
7
|
+
Yapton keeps ordinary Python syntax, data types, loops, expressions, and standard-library imports. It adds the following alternative words:
|
|
8
|
+
|
|
9
|
+
| Yapton | Python meaning |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `yap(...)` | `print(...)` |
|
|
12
|
+
| `spill(...)` | `input(...)`, converting number-looking input to `int` or `float` |
|
|
13
|
+
| `vibe name():` | `def name():` |
|
|
14
|
+
| `fanumtax math` | `import math` |
|
|
15
|
+
| `optionC` | `elif` |
|
|
16
|
+
| `otherwise` | `else` |
|
|
17
|
+
| `W` / `L` | `True` / `False` |
|
|
18
|
+
|
|
19
|
+
For example:
|
|
20
|
+
|
|
21
|
+
```yap
|
|
22
|
+
fanumtax math
|
|
23
|
+
|
|
24
|
+
vibe greet(name):
|
|
25
|
+
yap("Welcome,", name)
|
|
26
|
+
|
|
27
|
+
name = spill("What is your name? ")
|
|
28
|
+
greet(name)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Project roles
|
|
32
|
+
|
|
33
|
+
The codebase has three clear responsibilities:
|
|
34
|
+
|
|
35
|
+
| Part | Role |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `src/yapton/__init__.py` | The **Yapton language engine**. It translates Yapton keywords into Python tokens, provides `spill`, runs `.yap` files, and prints the slang reference. |
|
|
38
|
+
| `src/yapton/cli.py` | The **command-line interface**. It accepts `yap program.yap` and `yap --slang-help`, then calls the language engine. |
|
|
39
|
+
| `pyproject.toml` | The **package configuration**. It declares the Python requirement and installs the `yap` command. |
|
|
40
|
+
| `sample1.yap` to `sample7.yap` | **Example Yapton programs**, ordered from small language demonstrations to larger projects. |
|
|
41
|
+
| `yap.bat` | The **Windows launcher**. It runs `python -m yapton.cli`, so it never depends on a copied, moved, or stale virtual environment. |
|
|
42
|
+
|
|
43
|
+
## Requirements
|
|
44
|
+
|
|
45
|
+
- Python 3.10 or newer
|
|
46
|
+
- PowerShell, Command Prompt, or another terminal
|
|
47
|
+
- Git, only if you want to publish the project on GitHub
|
|
48
|
+
|
|
49
|
+
Check that Python is available:
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
py --version
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If `py` is not found, install Python from [python.org](https://www.python.org/downloads/) and make sure the installer option to add Python to PATH is enabled.
|
|
56
|
+
|
|
57
|
+
## Run it locally (Windows / PowerShell)
|
|
58
|
+
|
|
59
|
+
Open PowerShell in this project folder, then create a fresh virtual environment and install Yapton in editable mode:
|
|
60
|
+
|
|
61
|
+
```powershell
|
|
62
|
+
cd "C:\path\to\Yapton"
|
|
63
|
+
py -m venv .venv
|
|
64
|
+
.\.venv\Scripts\Activate.ps1
|
|
65
|
+
python -m pip install --upgrade pip
|
|
66
|
+
python -m pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Run an example:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
yap sample2.yap
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Or run the larger example:
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
yap sample5.yap
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
See the built-in language reference at any time:
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
yap --slang-help
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### If PowerShell blocks activation
|
|
88
|
+
|
|
89
|
+
Activation is optional. Use the environment's Python directly instead:
|
|
90
|
+
|
|
91
|
+
```powershell
|
|
92
|
+
.\.venv\Scripts\python.exe -m pip install -e .
|
|
93
|
+
.\.venv\Scripts\yap.exe sample2.yap
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Run a new program
|
|
97
|
+
|
|
98
|
+
1. Create a file ending in `.yap`, such as `hello.yap`.
|
|
99
|
+
2. Add Yapton/Python code.
|
|
100
|
+
3. Run `yap hello.yap` while the environment is active.
|
|
101
|
+
|
|
102
|
+
Indentation and colons work exactly like Python. Regular Python can be mixed with the Yapton keywords shown above.
|
|
103
|
+
|
|
104
|
+
### Sample guide
|
|
105
|
+
|
|
106
|
+
| File | Demonstrates |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| `sample1.yap` | Functions, loops, lists, conditions, and Yapton booleans. |
|
|
109
|
+
| `sample2.yap` | Adding two numbers entered by the user. |
|
|
110
|
+
| `sample3.yap` | Subtracting two numbers entered by the user. |
|
|
111
|
+
| `sample4.yap` | Checking whether a number is positive or negative. |
|
|
112
|
+
| `sample5.yap` | A menu-driven student score tracker using Yapton imports. |
|
|
113
|
+
| `sample6.yap` | The same student tracker, showing that regular Python `import` also works. |
|
|
114
|
+
| `sample7.yap` | A first-person 3D maze. Install its extra dependency first with `python -m pip install ursina`. |
|
|
115
|
+
|
|
116
|
+
### Why `yap` works reliably in this folder
|
|
117
|
+
|
|
118
|
+
Windows chooses `yap.bat` in the current folder before an installed `yap` command. This project launcher deliberately uses `python -m yapton.cli` instead of a hard-coded path to `venv\\Scripts\\python.exe`. That means it uses the same Python installation that installed Yapton and will not break merely because a virtual-environment folder was moved, deleted, or created on another computer.
|
|
119
|
+
|
|
120
|
+
## Put it on GitHub
|
|
121
|
+
|
|
122
|
+
1. Sign in to [GitHub](https://github.com/) and select **New repository**.
|
|
123
|
+
2. Name it `Yapton`, choose Public or Private, and **do not** initialize it with a README, `.gitignore`, or license—the project already has the first two.
|
|
124
|
+
3. In PowerShell, from this project folder, run the following. Replace `YOUR-USERNAME` with your GitHub username:
|
|
125
|
+
|
|
126
|
+
```powershell
|
|
127
|
+
cd "C:\path\to\Yapton"
|
|
128
|
+
git init
|
|
129
|
+
git add .
|
|
130
|
+
git commit -m "Initial commit: Yapton language"
|
|
131
|
+
git branch -M main
|
|
132
|
+
git remote add origin https://github.com/YOUR-USERNAME/Yapton.git
|
|
133
|
+
git push -u origin main
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
GitHub may ask you to sign in or create a personal access token when you push over HTTPS. If Git reports that a remote called `origin` already exists, update it instead:
|
|
137
|
+
|
|
138
|
+
```powershell
|
|
139
|
+
git remote set-url origin https://github.com/YOUR-USERNAME/Yapton.git
|
|
140
|
+
git push -u origin main
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The included `.gitignore` prevents virtual environments, cache files, and build outputs from being uploaded. Do not upload `.venv/` or `venv/`; each contributor should create their own using the local setup steps above.
|
|
144
|
+
|
|
145
|
+
### Privacy check before publishing
|
|
146
|
+
|
|
147
|
+
The publishable source files contain no personal names, email addresses, passwords, API keys, or local computer paths. The ignored `venv/` folder is machine-specific and must not be uploaded. The `.gitignore` also excludes virtual environments and `.env` files, which are common places for private settings. Before each push, review exactly what will be uploaded with:
|
|
148
|
+
|
|
149
|
+
```powershell
|
|
150
|
+
git status
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Contributing
|
|
154
|
+
|
|
155
|
+
When adding a slang keyword, update both `NAME_MAP` and `print_slang_help()` in `src/yapton/__init__.py`, then add or update a `.yap` example that demonstrates it. Before committing, run an example and `yap --slang-help` to confirm the command still works.
|
|
156
|
+
|
|
157
|
+
## Current status
|
|
158
|
+
|
|
159
|
+
Yapton is an early educational prototype. Because programs ultimately execute as Python, only run `.yap` files you trust.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "Yapton"
|
|
7
|
+
version = "0.1.2"
|
|
8
|
+
description = "Yapton is an fun Python library that helps kids learn how to code Python using fun slang-keywords"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
|
|
12
|
+
[tool.setuptools]
|
|
13
|
+
package-dir = {"" = "src"}
|
|
14
|
+
|
|
15
|
+
[tool.setuptools.packages.find]
|
|
16
|
+
where = ["src"]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
yap = "yapton.cli:main"
|
yapton-0.1.2/setup.cfg
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Yapton
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Yapton is an fun Python library that helps kids learn how to code Python using fun slang-keywords
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Dynamic: license-file
|
|
9
|
+
|
|
10
|
+
# Yapton
|
|
11
|
+
|
|
12
|
+
**Yapton is a small educational programming language that lets learners write Python-style programs with a few slang-inspired keywords.** A Yapton file (`.yap`) is translated to Python in memory and then run with the normal Python runtime. It is intended as a friendly bridge to Python, not as a replacement for it.
|
|
13
|
+
|
|
14
|
+
## What this project does
|
|
15
|
+
|
|
16
|
+
Yapton keeps ordinary Python syntax, data types, loops, expressions, and standard-library imports. It adds the following alternative words:
|
|
17
|
+
|
|
18
|
+
| Yapton | Python meaning |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| `yap(...)` | `print(...)` |
|
|
21
|
+
| `spill(...)` | `input(...)`, converting number-looking input to `int` or `float` |
|
|
22
|
+
| `vibe name():` | `def name():` |
|
|
23
|
+
| `fanumtax math` | `import math` |
|
|
24
|
+
| `optionC` | `elif` |
|
|
25
|
+
| `otherwise` | `else` |
|
|
26
|
+
| `W` / `L` | `True` / `False` |
|
|
27
|
+
|
|
28
|
+
For example:
|
|
29
|
+
|
|
30
|
+
```yap
|
|
31
|
+
fanumtax math
|
|
32
|
+
|
|
33
|
+
vibe greet(name):
|
|
34
|
+
yap("Welcome,", name)
|
|
35
|
+
|
|
36
|
+
name = spill("What is your name? ")
|
|
37
|
+
greet(name)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Project roles
|
|
41
|
+
|
|
42
|
+
The codebase has three clear responsibilities:
|
|
43
|
+
|
|
44
|
+
| Part | Role |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `src/yapton/__init__.py` | The **Yapton language engine**. It translates Yapton keywords into Python tokens, provides `spill`, runs `.yap` files, and prints the slang reference. |
|
|
47
|
+
| `src/yapton/cli.py` | The **command-line interface**. It accepts `yap program.yap` and `yap --slang-help`, then calls the language engine. |
|
|
48
|
+
| `pyproject.toml` | The **package configuration**. It declares the Python requirement and installs the `yap` command. |
|
|
49
|
+
| `sample1.yap` to `sample7.yap` | **Example Yapton programs**, ordered from small language demonstrations to larger projects. |
|
|
50
|
+
| `yap.bat` | The **Windows launcher**. It runs `python -m yapton.cli`, so it never depends on a copied, moved, or stale virtual environment. |
|
|
51
|
+
|
|
52
|
+
## Requirements
|
|
53
|
+
|
|
54
|
+
- Python 3.10 or newer
|
|
55
|
+
- PowerShell, Command Prompt, or another terminal
|
|
56
|
+
- Git, only if you want to publish the project on GitHub
|
|
57
|
+
|
|
58
|
+
Check that Python is available:
|
|
59
|
+
|
|
60
|
+
```powershell
|
|
61
|
+
py --version
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If `py` is not found, install Python from [python.org](https://www.python.org/downloads/) and make sure the installer option to add Python to PATH is enabled.
|
|
65
|
+
|
|
66
|
+
## Run it locally (Windows / PowerShell)
|
|
67
|
+
|
|
68
|
+
Open PowerShell in this project folder, then create a fresh virtual environment and install Yapton in editable mode:
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
cd "C:\path\to\Yapton"
|
|
72
|
+
py -m venv .venv
|
|
73
|
+
.\.venv\Scripts\Activate.ps1
|
|
74
|
+
python -m pip install --upgrade pip
|
|
75
|
+
python -m pip install -e .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Run an example:
|
|
79
|
+
|
|
80
|
+
```powershell
|
|
81
|
+
yap sample2.yap
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or run the larger example:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
yap sample5.yap
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
See the built-in language reference at any time:
|
|
91
|
+
|
|
92
|
+
```powershell
|
|
93
|
+
yap --slang-help
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### If PowerShell blocks activation
|
|
97
|
+
|
|
98
|
+
Activation is optional. Use the environment's Python directly instead:
|
|
99
|
+
|
|
100
|
+
```powershell
|
|
101
|
+
.\.venv\Scripts\python.exe -m pip install -e .
|
|
102
|
+
.\.venv\Scripts\yap.exe sample2.yap
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Run a new program
|
|
106
|
+
|
|
107
|
+
1. Create a file ending in `.yap`, such as `hello.yap`.
|
|
108
|
+
2. Add Yapton/Python code.
|
|
109
|
+
3. Run `yap hello.yap` while the environment is active.
|
|
110
|
+
|
|
111
|
+
Indentation and colons work exactly like Python. Regular Python can be mixed with the Yapton keywords shown above.
|
|
112
|
+
|
|
113
|
+
### Sample guide
|
|
114
|
+
|
|
115
|
+
| File | Demonstrates |
|
|
116
|
+
| --- | --- |
|
|
117
|
+
| `sample1.yap` | Functions, loops, lists, conditions, and Yapton booleans. |
|
|
118
|
+
| `sample2.yap` | Adding two numbers entered by the user. |
|
|
119
|
+
| `sample3.yap` | Subtracting two numbers entered by the user. |
|
|
120
|
+
| `sample4.yap` | Checking whether a number is positive or negative. |
|
|
121
|
+
| `sample5.yap` | A menu-driven student score tracker using Yapton imports. |
|
|
122
|
+
| `sample6.yap` | The same student tracker, showing that regular Python `import` also works. |
|
|
123
|
+
| `sample7.yap` | A first-person 3D maze. Install its extra dependency first with `python -m pip install ursina`. |
|
|
124
|
+
|
|
125
|
+
### Why `yap` works reliably in this folder
|
|
126
|
+
|
|
127
|
+
Windows chooses `yap.bat` in the current folder before an installed `yap` command. This project launcher deliberately uses `python -m yapton.cli` instead of a hard-coded path to `venv\\Scripts\\python.exe`. That means it uses the same Python installation that installed Yapton and will not break merely because a virtual-environment folder was moved, deleted, or created on another computer.
|
|
128
|
+
|
|
129
|
+
## Put it on GitHub
|
|
130
|
+
|
|
131
|
+
1. Sign in to [GitHub](https://github.com/) and select **New repository**.
|
|
132
|
+
2. Name it `Yapton`, choose Public or Private, and **do not** initialize it with a README, `.gitignore`, or license—the project already has the first two.
|
|
133
|
+
3. In PowerShell, from this project folder, run the following. Replace `YOUR-USERNAME` with your GitHub username:
|
|
134
|
+
|
|
135
|
+
```powershell
|
|
136
|
+
cd "C:\path\to\Yapton"
|
|
137
|
+
git init
|
|
138
|
+
git add .
|
|
139
|
+
git commit -m "Initial commit: Yapton language"
|
|
140
|
+
git branch -M main
|
|
141
|
+
git remote add origin https://github.com/YOUR-USERNAME/Yapton.git
|
|
142
|
+
git push -u origin main
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
GitHub may ask you to sign in or create a personal access token when you push over HTTPS. If Git reports that a remote called `origin` already exists, update it instead:
|
|
146
|
+
|
|
147
|
+
```powershell
|
|
148
|
+
git remote set-url origin https://github.com/YOUR-USERNAME/Yapton.git
|
|
149
|
+
git push -u origin main
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The included `.gitignore` prevents virtual environments, cache files, and build outputs from being uploaded. Do not upload `.venv/` or `venv/`; each contributor should create their own using the local setup steps above.
|
|
153
|
+
|
|
154
|
+
### Privacy check before publishing
|
|
155
|
+
|
|
156
|
+
The publishable source files contain no personal names, email addresses, passwords, API keys, or local computer paths. The ignored `venv/` folder is machine-specific and must not be uploaded. The `.gitignore` also excludes virtual environments and `.env` files, which are common places for private settings. Before each push, review exactly what will be uploaded with:
|
|
157
|
+
|
|
158
|
+
```powershell
|
|
159
|
+
git status
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Contributing
|
|
163
|
+
|
|
164
|
+
When adding a slang keyword, update both `NAME_MAP` and `print_slang_help()` in `src/yapton/__init__.py`, then add or update a `.yap` example that demonstrates it. Before committing, run an example and `yap --slang-help` to confirm the command still works.
|
|
165
|
+
|
|
166
|
+
## Current status
|
|
167
|
+
|
|
168
|
+
Yapton is an early educational prototype. Because programs ultimately execute as Python, only run `.yap` files you trust.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/Yapton.egg-info/PKG-INFO
|
|
5
|
+
src/Yapton.egg-info/SOURCES.txt
|
|
6
|
+
src/Yapton.egg-info/dependency_links.txt
|
|
7
|
+
src/Yapton.egg-info/entry_points.txt
|
|
8
|
+
src/Yapton.egg-info/top_level.txt
|
|
9
|
+
src/yapton/__init__.py
|
|
10
|
+
src/yapton/cli.py
|
|
11
|
+
src/yapton.egg-info/PKG-INFO
|
|
12
|
+
src/yapton.egg-info/SOURCES.txt
|
|
13
|
+
src/yapton.egg-info/dependency_links.txt
|
|
14
|
+
src/yapton.egg-info/entry_points.txt
|
|
15
|
+
src/yapton.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
yapton
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import io
|
|
3
|
+
import tokenize
|
|
4
|
+
|
|
5
|
+
# Yapton -> Python keyword / literal mapping
|
|
6
|
+
# We only touch NAME tokens, so strings and comments stay the same.
|
|
7
|
+
NAME_MAP = {
|
|
8
|
+
# control flow
|
|
9
|
+
"optionC": "elif", # optionC -> elif
|
|
10
|
+
"otherwise": "else", # otherwise -> else
|
|
11
|
+
|
|
12
|
+
# booleans
|
|
13
|
+
"W": "True", # W -> True
|
|
14
|
+
"L": "False", # L -> False
|
|
15
|
+
|
|
16
|
+
# functions / I/O
|
|
17
|
+
"yap": "print", # yap(...) -> print(...)
|
|
18
|
+
# NOTE: spill is implemented as a real Python helper function below,
|
|
19
|
+
# not just a rename, so it can auto-convert numbers.
|
|
20
|
+
|
|
21
|
+
# function definition
|
|
22
|
+
"vibe": "def", # vibe foo(): -> def foo():
|
|
23
|
+
|
|
24
|
+
# imports
|
|
25
|
+
"fanumtax": "import", # fanumtax math -> import math
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def spill(prompt: str = "") -> object:
|
|
30
|
+
"""Yapton input function.
|
|
31
|
+
|
|
32
|
+
Behaves like Python's input(), but tries to convert what the user typed
|
|
33
|
+
into an int or float. If that fails, it returns the raw string.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
raw = input(prompt)
|
|
37
|
+
# Try int first
|
|
38
|
+
try:
|
|
39
|
+
return int(raw)
|
|
40
|
+
except ValueError:
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
# Then try float
|
|
44
|
+
try:
|
|
45
|
+
return float(raw)
|
|
46
|
+
except ValueError:
|
|
47
|
+
return raw
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def transpile(source: str) -> str:
|
|
51
|
+
"""Turn Yapton source into real Python source.
|
|
52
|
+
|
|
53
|
+
This uses the tokenize module so we only rewrite identifier tokens,
|
|
54
|
+
not things inside strings or comments. That way Python's own
|
|
55
|
+
features (types, lists, slicing, loops, etc.) just work.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
out_tokens = []
|
|
59
|
+
|
|
60
|
+
# tokenize.tokenize works on bytes; we wrap the string in a BytesIO
|
|
61
|
+
byte_stream = io.BytesIO(source.encode("utf-8"))
|
|
62
|
+
try:
|
|
63
|
+
for tok in tokenize.tokenize(byte_stream.readline):
|
|
64
|
+
tok_type = tok.type
|
|
65
|
+
tok_string = tok.string
|
|
66
|
+
|
|
67
|
+
# Replace only identifier / name tokens that are in our mapping
|
|
68
|
+
if tok_type == tokenize.NAME and tok_string in NAME_MAP:
|
|
69
|
+
tok_string = NAME_MAP[tok_string]
|
|
70
|
+
tok = tokenize.TokenInfo(tok_type, tok_string, tok.start, tok.end, tok.line)
|
|
71
|
+
|
|
72
|
+
out_tokens.append(tok)
|
|
73
|
+
except tokenize.TokenError as exc:
|
|
74
|
+
raise SyntaxError(f"Yapton could not be tokenized: {exc}")
|
|
75
|
+
|
|
76
|
+
# untokenize back to Python code
|
|
77
|
+
return tokenize.untokenize(out_tokens).decode("utf-8")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def run_file(path: str) -> None:
|
|
81
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
82
|
+
source = f.read()
|
|
83
|
+
|
|
84
|
+
python_code = transpile(source)
|
|
85
|
+
|
|
86
|
+
# Execute the transpiled Python. We let Python handle all the real
|
|
87
|
+
# work: numbers, strings, lists, slicing, loops, functions, imports, etc.
|
|
88
|
+
# Expose spill() so Yapton code can call it directly.
|
|
89
|
+
globals_dict = {"__name__": "__main__", "spill": spill}
|
|
90
|
+
try:
|
|
91
|
+
exec(python_code, globals_dict)
|
|
92
|
+
except Exception as exc: # noqa: BLE001
|
|
93
|
+
# Wrap any Python error with your custom prefix.
|
|
94
|
+
print(f"error 67: {exc.__class__.__name__}: {exc}")
|
|
95
|
+
sys.exit(1)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def print_slang_help() -> None:
|
|
99
|
+
print("Yapton slang dictionary:\n")
|
|
100
|
+
print(" W -> True (boolean)")
|
|
101
|
+
print(" L -> False (boolean)")
|
|
102
|
+
print(" if -> if (same as Python)")
|
|
103
|
+
print(" optionC -> elif")
|
|
104
|
+
print(" otherwise -> else")
|
|
105
|
+
print(" yap -> print")
|
|
106
|
+
print(" spill -> input (auto-converts to number when possible)")
|
|
107
|
+
print(" vibe -> def (define a function)")
|
|
108
|
+
print(" fanumtax -> import (bring in Python modules)")
|
|
109
|
+
print(" # -> comment (same as Python)")
|
|
110
|
+
print(" type(...) -> same as Python type() and casts")
|
|
111
|
+
print(" lists, slicing, for/while loops -> same as Python syntax")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
from . import print_slang_help, run_file
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def main(argv: list[str] | None = None) -> None:
|
|
7
|
+
if argv is None:
|
|
8
|
+
argv = sys.argv[1:]
|
|
9
|
+
|
|
10
|
+
# Usage:
|
|
11
|
+
# yap program.yap
|
|
12
|
+
# yap --slang-help
|
|
13
|
+
if len(argv) == 1 and argv[0] == "--slang-help":
|
|
14
|
+
print_slang_help()
|
|
15
|
+
raise SystemExit(0)
|
|
16
|
+
|
|
17
|
+
if len(argv) != 1:
|
|
18
|
+
print("Usage: yap <program.yap> | --slang-help")
|
|
19
|
+
raise SystemExit(1)
|
|
20
|
+
|
|
21
|
+
run_file(argv[0])
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__": # pragma: no cover
|
|
25
|
+
main()
|