Skip to content

Commit 05da712

Browse files
committed
Created and updated files used on github.
- Created CONTRIBUTING.md and PULL_REQUEST_TEMPLATE.md. - Updated CODEOWNERS - Updated README.md
1 parent 0b97aaf commit 05da712

4 files changed

Lines changed: 103 additions & 114 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!--- Provide a general summary of your changes in the Title above -->
2+
3+
## Description
4+
5+
<!--- Describe your changes in detail -->
6+
7+
## Motivation and Context
8+
9+
<!--- What language did you add? Or what problem does it solve? -->

CODEOWNERS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# Russian Examples, Documentation
1+
# Russian/Gen Alpha Examples, Documentation
22
examples/ru/* @CalciumKing
3+
examples/gen_alpha/* @CalciumKing
34
lang.csv @CalciumKing
45
README.md @CalciumKing
6+
CONTRIBUTING.md @CalciumKing
7+
.github/* @CalciumKing
8+
LICENSE @CalciumKing
59

610
# Thai Examples, Debugger File
711
examples/th/* @petepoop

CONTRIBUTING.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# CONTRIBUTING
2+
3+
This project was developed by two friends.
4+
Contributions are welcome! This repo is collaborative,
5+
so if you want to add a solution in a new language or just
6+
improve some code that you think that can be improved, follow these steps:
7+
8+
9+
## 1. Fork it
10+
11+
You can get your own fork/copy of [Translatable Python](https://github.com/CalciumKing/Translatable-Python) by using the Fork button.
12+
13+
## 2. Start coding!
14+
15+
Once you have forked the repo, modify `lang.csv` with your language's keywords,
16+
and make some example programs in a dedicated folder inside `examples/`.
17+
Once your program compiles correctly, move your updated `lang.csv` file to
18+
your new folder and rename `lang.csv` to an abbreviation of your language
19+
with the `.csv` file extension. Ex: `ru.csv` or `thai.csv`.
20+
21+
For a PR to be approved and merged please note:
22+
23+
- After modifying `lang.csv` and creating your custom file, revert `lang.csv`
24+
back to its original state for future users to use.
25+
- Do not add more files to the project root, add files to their
26+
own language folder inside `examples/`.
27+
- Do not delete folders/files
28+
29+
## 3. Ready, Steady, Go...
30+
31+
Once you have completed these steps, you are ready to start contributing
32+
by checking creating a pull request and filling out our
33+
[pull request template](https://github.com/CalciumKing/Translatable-Python/blob/main/.github/PULL_REQUEST_TEMPLATE.md).
34+
35+
## 4. Give this Project a Star
36+
37+
If you liked working on this project, please share this project as
38+
much as you can and star this project to help as many people in open source as you can.

README.md

Lines changed: 51 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,65 @@
1-
# Gen Alpha Programming (GAP)
1+
# Translatable Python (`.tpy`)
22

3-
Gen Alpha Programming (GAP) is a fun, experimental Python-like language that uses Gen Alpha slang for its syntax. It's designed as a demonstration of how a simple interpreter can be built and to provide a humorous take on programming languages. It is *not* intended for serious software development, but rather as an educational and entertaining project.
3+
Translatable Python (TPY) is a lightweight python compiler that lets you swap Python keywords with your own words.
4+
Whether you want to code in slang, inside jokes, or another language, you can!
45

5-
**Important Note:** This is a simplified interpreter, *not* a full compiler. It translates GAP code into standard Python and then executes it. This means it has limitations compared to a fully compiled language.
6+
`lang.py` translates specified keywords contained in `lang.csv` into valid Python code and then executes that python
7+
code.
68

7-
## Installation
8-
9-
You don't need to "install" anything special. Just make sure you have Python 3 (preferably 3.10 or later, for `match`/`case` support) installed on your system. Then, save the interpreter code (provided in the `genalpha_python.py` file) to your computer.
10-
11-
## Running GAP Code
9+
This project also has the potential to translate any language supported by UTF-8 into valid python code.
1210

13-
There are two ways to run GAP code:
14-
15-
1. **Interactive Mode:**
11+
## Installation
1612

17-
Open your terminal or command prompt and run the interpreter script:
13+
You don't need to "install" anything special. Just make sure you have Python 3 (preferably 3.10 or later, for
14+
`match`/`case` support) installed on your system.
1815

19-
```bash
20-
python gena.py
21-
```
16+
## Running Translatable Python
2217

23-
You'll see a `gap> ` prompt. Type your GAP code line by line, and it will be executed immediately. Type `exit` to quit the interactive mode. Multi-line statements (like `if`, `for`, `while`, and function definitions) are supported; the interpreter will wait for the complete block (indicated by a colon at the end of the initial line) before executing.
18+
1. **Specify Keywords In Your Language**
19+
20+
To specify keywords, open `lang.csv` and add each translation in place of the current translation in the format
21+
`PythonKeyword,TranslatedKeyword`. The first column must be the original Python keyword (e.g. if, else, print),
22+
and the second column is your custom translation. Do not add multiple keywords or different translatable
23+
keywords for the same Python keyword, each line should contain strictly a python keyword and a unique
24+
translatable keyword. Make sure to save the file with UTF-8 encoding if your language uses special characters.
25+
The program will automatically read these pairs and use them to translate your code.
2426

2527
2. **File Input:**
2628

27-
Create a text file containing your GAP code (e.g., `my_program.gap`). Then, run the interpreter with the filename as an argument:
29+
Create a `.tpy` file containing your translatable code (e.g., `example.tpy`). Then, run the compiler with the
30+
filename as an argument:
2831

2932
```bash
30-
python gena.py my_program.gap
33+
python lang.py example.tpy
3134
```
3235

33-
The interpreter will read and execute the code from the file.
34-
35-
## Syntax Overview
36-
37-
Here's a mapping of Gen Alpha slang to their Python equivalents, along with examples:
38-
39-
| Gen Alpha Slang | Python Equivalent | Description | Example |
40-
|-----------------|------------------------|---------------------------------------------|-----------------------------------------------|
41-
| `skibidi` | `None` / `def` | No value / Function definition | `skibidi my_var` / `skibidi my_func():` |
42-
| `rizz` | `int` | Integer type hint (not strictly enforced) | `rizz x equals 5` |
43-
| `chad` | `float` | Floating-point type hint (not enforced) | `chad pi equals 3.14159` |
44-
| `gigachad` | `float` |Floating-point number (same as chad) |`gigachad big_num = 12345.67` |
45-
| `yap` | `str` | String type hint | `yap my_string equals "Hello"` |
46-
| `cap` | `bool` | Boolean type hint (not enforced) | `cap is_true equals W` |
47-
| `W` | `True` | Boolean True | `cap flag equals W` |
48-
| `L` | `False` | Boolean False | `cap another_flag equals L` |
49-
| `edgy` | `if` | If statement | `edgy x greater_than y lbrace ...` |
50-
| `amogus` | `else` | Else statement | `edgy x greater_than y lbrace ... amogus lbrace ...` |
51-
| `goon` | `while` | While loop | `goon x less_than 10 lbrace ...` |
52-
| `bruh` | `break` | Break statement (exit loop) | `goon W lbrace edgy condition lbrace bruh` |
53-
| `grind` | `continue` | Continue statement (skip to next iteration) | `flex i in range(10) lbrace edgy i modulo 2 equals_equals 0 lbrace grind ...` |
54-
| `flex` | `for` | For loop | `flex i in range(5) lbrace ...` |
55-
| `bussin` | `return` (limited) | Return statement (very basic implementation) | `skibidi my_func() lbrace bussin 42` |
56-
| `print` | `print` | Print statement | `print("Hello, world!")` |
57-
| `input` |`input` | Read user input |`rant user_name = input("Enter name: ")` |
58-
| `ohio` | `match` | Match statement (Python 3.10+) | `ohio value lbrace ...` |
59-
| `sigma_rule` | `case` | Case within a match statement | `ohio x lbrace sigma_rule 1: ...` |
60-
| `based` | `case _` | Default case in a match statement | `ohio x lbrace ... based: ...` |
61-
| `cringe` | `raise` | Raise an exception | `cringe ValueError("Something went wrong")` |
62-
| `equals` | `=` | Assignment operator | `rizz x equals 10` |
63-
| `plus` | `+` | Addition operator | `x plus y` |
64-
| `minus` | `-` | Subtraction operator | `x minus y` |
65-
| `times` | `*` | Multiplication operator | `x times y` |
66-
| `divide` | `/` | Division operator | `x divide y` |
67-
| `modulo` | `%` | Modulo operator | `x modulo y` |
68-
| `not` | `not` | Logical NOT operator | `not cap` |
69-
| `and` | `and` | Logical AND operator | `x greater_than 0 and x less_than 10` |
70-
| `or` | `or` | Logical OR operator | `x equals_equals 0 or y equals_equals 0` |
71-
| `equals_equals` | `==` | Equality comparison operator | `x equals_equals y` |
72-
| `not_equals` | `!=` | Inequality comparison operator | `x not_equals y` |
73-
| `less_than` | `<` | Less than comparison operator | `x less_than y` |
74-
| `greater_than` | `>` | Greater than comparison operator | `x greater_than y` |
75-
| `less_than_or_equal` | `<=` | Less than or equal to comparison | `x less_than_or_equal y` |
76-
| `greater_than_or_equal` | `>=` | Greater than or equal to comparison | `x greater_than_or_equal y` |
77-
| `semicolon` | *(removed)* | Semicolons are removed | |
78-
| `comma` | `,` | Commas are kept | |
79-
|`lparen` | `(` | Left Parenthesis | `print(x)` |
80-
|`rparen` | `)` | Right Parenthesis | `print(x)` |
81-
|`lbrace` |`:` | Colon (for blocks) | |
82-
|`rant` |`str` | Strings |`rant name = "John"` |
83-
84-
**Key Concepts:**
85-
86-
* **Indentation:** GAP, like Python, uses indentation (4 spaces recommended) to define code blocks (e.g., inside `if`, `for`, `while`, and function definitions).
87-
* **Functions:** Functions are defined using `skibidi function_name(arguments) lbrace ...`. The `bussin` keyword is used for a very basic form of return (see limitations below).
88-
* **Strings:** Strings are supported using the `rant` keyword.
89-
90-
**Limitations:**
91-
92-
* **Simplified Interpreter:** This is *not* a full-featured programming language. It's a demonstration project.
93-
* **Limited `return`:** The `bussin` keyword provides only very basic return functionality. It works primarily for simple expressions at the top level (outside of functions) and stores the "returned" value in a special variable. It doesn't handle complex return scenarios within nested functions.
94-
* **No Classes:** Object-oriented programming features (classes, objects, methods) are not supported.
95-
* **No Modules/Imports:** There's no support for importing external modules.
96-
* **Limited Error Handling:** The error messages might not always be very helpful, especially if the error is caused by the underlying Python code generated by the interpreter.
97-
* **Global Scope Only:** All variables are in a single global scope. There's no concept of local variables within functions (beyond function parameters).
98-
* **No Type Enforcement** Type Hints like `rizz` are replaced but python does not enforce them.
99-
100-
**Example Program (example.gap):**
101-
```Example.gap
102-
skibidi greet(yap name) lbrace
103-
print("Hello, " plus name plus "!")
104-
105-
skibidi factorial(rizz n) lbrace
106-
edgy n equals_equals 0 lbrace
107-
bussin 1
108-
amogus lbrace
109-
bussin n times factorial(n minus 1)
110-
111-
rizz num equals 5
112-
rizz fact equals factorial(num)
113-
print("Factorial of " plus str(num) plus " is " plus str(fact)) # Convert numbers to strings for printing
114-
115-
greet("World")
116-
117-
flex i in range(1, 6) lbrace # Loop from 1 to 5
118-
print("Current number: " plus str(i))
119-
120-
goon W lbrace #Infinite loop
121-
rant user_input = input("Enter a number (or 'quit' to exit): ")
122-
edgy user_input equals_equals "quit" lbrace
123-
bruh
124-
amogus:
125-
rizz number = int(user_input)
126-
print("You entered: " plus str(number))
127-
rbrace
36+
## Example
37+
38+
1. `lang.csv` (Example):
39+
```csv
40+
def,myfunc
41+
return,sendback
42+
if,whenever
43+
else,otherwise
44+
print,say
45+
```
46+
47+
2. Custom Code (hello.tpy):
48+
```text
49+
myfunc greet(name) {
50+
say("Hello " + name)
51+
sendback "done"
52+
}
53+
54+
greet("World")
55+
```
56+
57+
3. Run It:
58+
```bash
59+
python lang.py hello.tpy
60+
```
61+
62+
4. Output:
63+
```text
64+
Hello World
65+
```

0 commit comments

Comments
 (0)