bracket-lang 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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tc0512
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: bracket-lang
3
+ Version: 0.1.0
4
+ Requires-Python: >=3.8
5
+ License-File: LICENSE
6
+ Dynamic: license-file
7
+ Dynamic: requires-python
@@ -0,0 +1,106 @@
1
+ # bracket
2
+ python制作的转译型简单编程语言
3
+
4
+ ## 1 安装
5
+ ```bash
6
+ pip install bracket
7
+ ```
8
+
9
+ ## 2 Hello world
10
+ ```bracket
11
+ [INFO] ["Hello world!"]
12
+ ```
13
+
14
+ ## 3 基本语法
15
+ ```bracket
16
+ # 打印
17
+ [INFO] ["这是一段文本"]
18
+ [INFO] ["Loading...", end=" "]
19
+ [INFO] ["complete"]
20
+
21
+ # 变量
22
+ [VAR] [integer] [2]
23
+ [VAR] [floating_point] [3.0]
24
+ [VAR] [string] ["abc"]
25
+ [VAR] [lst] [[1, 2, 3, 4, 5]]
26
+ [VAR] [t] [(1, 2, 3)]
27
+ [VAR] [dict] [{1: 1, 2: 4, 3: 9}]
28
+ [INFO] [integer, floating_point, string, lst, t, dict]
29
+
30
+ # 输入
31
+ [VAR] [short] [INPUT] [单行文本] [False]
32
+ [VAR] [long] [INPUT] [多行文本] [True]
33
+ [INFO] ["您这两次分别输入了: "]
34
+ [INFO] [short]
35
+ [INFO] [long]
36
+
37
+ # 分支语句
38
+ [VAR] [a] [6]
39
+ [IF] [a>0]
40
+ [INFO] ["正数"]
41
+ [ELSEIF] [a==0]
42
+ [INFO] ["零"]
43
+ [ELSE]
44
+ [INFO] ["负数"]
45
+
46
+ # 循环
47
+ [VAR] [total] [0]
48
+ [FOR] [i] [1, 101, 1]
49
+ [VAR] [total] [total+i]
50
+ [INFO] ["1~100的和:", total]
51
+ [VAR] [i] [0]
52
+ [WHILE] [i<10]
53
+ [INFO] [i]
54
+ [VAR] [i] [i+1]
55
+ [LOOP]
56
+ [INFO] [i]
57
+ [IF] [i==100]
58
+ [BREAK]
59
+ [VAR] [i] [i+1]
60
+
61
+ # GUI
62
+ [USE] [TKGUI]
63
+ [VAR] [root] [TKGUI.Tk()]
64
+ root.title("Hello bracket")
65
+ root.geometry("300x200")
66
+ [VAR] [label] [TKGUI.Label(root, text="Hello, World!")]
67
+ label.pack()
68
+ root.mainloop()
69
+ ```
70
+ 输出:
71
+ ```text
72
+ 这是一段文本
73
+ Loading... complete
74
+ 2 3.0 abc [1, 2, 3, 4, 5] (1, 2, 3) {1: 1, 2: 4, 3: 9}
75
+ 单行文本: 1
76
+ 多行文本: 2
77
+ 3
78
+ 您这两次分别输入了
79
+ 1
80
+ 2
81
+ 3
82
+ 正数
83
+ 5050
84
+ 1
85
+ 2
86
+ 3
87
+ ...
88
+ 100
89
+ ```
90
+ ![窗口显示: ](./TKGUI_helloHello.jpg)
91
+
92
+ ## 4 命令行工具参数
93
+ | 参数 | 用法 |
94
+ | ------ | ------ |
95
+ | `--help` `-h` | 帮助 |
96
+ | `build` | 转译 |
97
+ | `run` | 转译运行 |
98
+
99
+ ## 6 注意事项
100
+ 1. `INFO`的参数与python的`print`基本相同
101
+ 2. `[VAR] [lst] [[1, 2, 3, 4, 5]]`是真正的列表, `[VAR] [t] [1, 2, 3, 4, 5]`是元组
102
+ 3. `FOR`必须要写三个参数
103
+ 4. `[LOOP]`是无限循环, 与`[WHILE] [True]`等效
104
+ 5. 变量名不能与bracket关键字和python关键字重名
105
+ 6. bracket语言不兼容python的列表推导式, 三元表达式等
106
+ 7. bracket内置轻量编辑器bkted
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env python3
2
+ # bracket/BRANCH.py
3
+ # manage the branch sentences
4
+
5
+ # [IF] [<cond>] → if <cond>:
6
+ def IF_to_if(code: str):
7
+ code = code.lstrip()
8
+ keyword, cond = code.split(" ", 1)
9
+ if keyword!="[IF]":
10
+ raise SyntaxError(f"Expect `[IF]` got {keyword}")
11
+ text = cond.removeprefix("[").removesuffix("]")
12
+ return f"if {text}:"
13
+
14
+ # [ELSEIF] [<cond>] → elif <cond>:
15
+ def ELSEIF_to_elif(code: str):
16
+ code = code.lstrip()
17
+ keyword, cond = code.split(" ", 1)
18
+ if keyword!="[ELSEIF]":
19
+ raise SyntaxError(f"Expect `[ELSEIF]` got {keyword}")
20
+ text = cond.removeprefix("[").removesuffix("]")
21
+ return f"elif {text}:"
22
+
23
+ # [ELSE] → else:
24
+ def ELSE_to_else(code: str):
25
+ code = code.lstrip()
26
+ if code!="[ELSE]":
27
+ raise SyntaxError(f"Expect `[ELSE]` got {code}")
28
+ return "else:"
29
+
30
+ def transpile_line(line: str):
31
+ indent = len(line) - len(line.lstrip())
32
+ stripped = line.lstrip()
33
+ if not stripped:
34
+ return ""
35
+ if stripped.startswith("[IF]"):
36
+ return " " * indent + IF_to_if(stripped)
37
+ elif stripped.startswith("[ELSEIF]"):
38
+ return " " * indent + ELSEIF_to_elif(stripped)
39
+ elif stripped == "[ELSE]":
40
+ return " " * indent + ELSE_to_else(stripped)
41
+ else:
42
+ return " " * indent + f"# UNKNOWN: {stripped}"
43
+
44
+ def transpile(code: str):
45
+ lines = code.splitlines()
46
+ result = []
47
+ for line in lines:
48
+ result.append(transpile_line(line))
49
+ return "\n".join(result)
@@ -0,0 +1,14 @@
1
+ # bracket/IMPORTLIB.py
2
+ # manage libraries importing
3
+
4
+ # [USE] [<lib>] → import <lib>
5
+ def USE_to_import(code: str):
6
+ code = code.lstrip()
7
+ keyword, lib = code.split(" ", 1)
8
+ if keyword!="[USE]":
9
+ raise SyntaxError(f"Expect `[USE]` got {keyword}")
10
+ key = lib.removeprefix("[").removesuffix("]")
11
+ lib_dict = {
12
+ "TKGUI": "tkinter as TKGUI"
13
+ }
14
+ return f"import {lib_dict[key]}"
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env python3
2
+ # bracket/IO.py
3
+ # manage I/O operation
4
+
5
+ # [INFO] [<text>] → print(<text>)
6
+ def INFO_to_print(code: str):
7
+ code = code.lstrip()
8
+ keyword, text = code.split(" ", 1)
9
+ if keyword!="[INFO]":
10
+ raise SyntaxError(f"Expected `INFO` got `{keyword}`.")
11
+ text = text.removeprefix("[").removesuffix("]")
12
+ return f"print({text})"
13
+
14
+ # [VAR] [<var name>] [INPUT] [<tip word> (don't need quotation marks)] [<multilines> (bool)] → var = input(<tip word>)
15
+ def INPUT_to_input(code: str) -> str:
16
+ code = code.lstrip()
17
+ rest = code.split(" ", 1)[1]
18
+ inner = rest.removeprefix("[").removesuffix("]")
19
+ parts = inner.split("] [")
20
+ if len(parts) != 4:
21
+ raise SyntaxError("Usage: [VAR] [<var name>] [INPUT] [<tip word> (don't need quotation marks)] [<multilines> (bool)]")
22
+ var_name = parts[0].strip()
23
+ keyword = parts[1]
24
+ tip_word = parts[2].strip()
25
+ multilines = parts[3].lower() in ("true", "1", "yes", "on")
26
+ if not var_name:
27
+ raise SyntaxError("Var name cannot be empty.")
28
+ if not var_name.isidentifier():
29
+ raise SyntaxError(f"Invalid var name: {var_name}.")
30
+ if keyword != "INPUT":
31
+ raise SyntaxError(f"Expected `INPUT`, got `{keyword}`.")
32
+ if not tip_word:
33
+ raise SyntaxError("Tip word cannot be empty")
34
+ if multilines:
35
+ return f'''\
36
+ print("{tip_word} (use EOF to finish)")
37
+ lines = []
38
+ while True:
39
+ try:
40
+ line = input()
41
+ except EOFError:
42
+ break
43
+ except KeyboardInterrupt:
44
+ print("\\nCanceled input.")
45
+ break
46
+ lines.append(line)
47
+ {var_name} = "\\n".join(lines)
48
+ '''
49
+ else:
50
+ return f'{var_name} = input("{tip_word}: ")'
51
+
52
+ def transpile_line(line: str): #Transpile one line of bracket code and handle the tabs.
53
+ indent = len(line) - len(line.lstrip())
54
+ stripped = line.lstrip()
55
+
56
+ if stripped.startswith("[INFO]"):
57
+ return " " * indent + INFO_to_print(stripped)
58
+ elif "[INPUT]" in stripped:
59
+ return " " * indent + INPUT_to_input(stripped)
60
+ elif stripped.startswith("[VAR]"):
61
+ return " " * indent + VAR_to_varname_equal(stripped)
62
+ else:
63
+ return " " * indent + f"# UNKNOWN: {stripped}"
64
+
65
+
66
+ def transpile(code: str) -> str: #Transpile multiple lines of bracket code.
67
+ """转译多行 bracket 代码"""
68
+ lines = code.splitlines()
69
+ result = []
70
+ for line in lines:
71
+ if line.strip() == "":
72
+ result.append("")
73
+ else:
74
+ result.append(transpile_line(line))
75
+ return "\n".join(result)
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env python3
2
+ # bracket/LOOP.py
3
+ # manage the loop sentences
4
+
5
+ # [FOR] [<range var>] [<start>, <end>, <step length>] → for <range var> in range(<start>, <end>, <step length>)
6
+ def FOR_to_for(code: str) -> str:
7
+ code = code.lstrip()
8
+ keyword, rest = code.split(" ", 1)
9
+ if keyword != "[FOR]":
10
+ raise SyntaxError(f"Expected `[FOR]` got `{keyword}`")
11
+ var_part, range_part = rest.split(" ", 1)
12
+ var = var_part.removeprefix("[").removesuffix("]")
13
+ range_args = range_part.removeprefix("[").removesuffix("]")
14
+ parts = [p.strip() for p in range_args.split(",")]
15
+ if len(parts)!=3:
16
+ raise SyntaxError("[FOR] needs 3 range arguments")
17
+ start, end, step = parts
18
+ return f"for {var} in range({start}, {end}, {step}):"
19
+
20
+ # [WHILE] [<cond>] → while <cond>:
21
+ def WHILE_to_while(code: str):
22
+ code = code.lstrip()
23
+ keyword, cond = code.split(" ", 1)
24
+ if keyword!="[WHILE]":
25
+ raise SyntaxError(f"Expect `[WHILE]` got {keyword}")
26
+ text = cond.removeprefix("[").removesuffix("]")
27
+ return f"while {text}:"
28
+
29
+ # [LOOP] → while True:
30
+ def LOOP_to_while_True(code: str):
31
+ code = code.lstrip()
32
+ if code!="[LOOP]":
33
+ raise SyntaxError(f"Expect `[LOOP]` got {code}")
34
+ return "while True:"
35
+
36
+ # [CONTINUE] → continue
37
+ def CONTINUE_to_continue(code: str):
38
+ code = code.lstrip()
39
+ if code!="[CONTINUE]":
40
+ raise SyntaxError(f"Expect `[CONTINUE]` got {code}")
41
+ return "continue"
42
+
43
+ # [BREAK] → break
44
+ def BREAK_to_break(code: str):
45
+ code = code.lstrip()
46
+ if code!="[BREAK]":
47
+ raise SyntaxError(f"Expect `[BREAK]` got {code}")
48
+ return "break"
49
+
50
+ def transpile_line(line: str) -> str:
51
+ indent = len(line) - len(line.lstrip())
52
+ stripped = line.lstrip()
53
+ if not stripped:
54
+ return ""
55
+ if stripped.startswith("[FOR]"):
56
+ return " " * indent + FOR_to_for(stripped)
57
+ elif stripped.startswith("[WHILE]"):
58
+ return " " * indent + WHILE_to_while(stripped)
59
+ elif stripped == "[LOOP]":
60
+ return " " * indent + LOOP_to_while_True(stripped)
61
+ elif stripped == "[BREAK]":
62
+ return " " * indent + BREAK_to_break(stripped)
63
+ elif stripped == "[CONTINUE]":
64
+ return " " * indent + CONTINUE_to_continue(stripped)
65
+ else:
66
+ return " " * indent + f"# UNKNOWN: {stripped}"
67
+
68
+ def transpile(code: str):
69
+ lines = code.splitlines()
70
+ result = []
71
+ for line in lines:
72
+ if line.strip():
73
+ result.append(transpile_line(line))
74
+ else:
75
+ result.append("")
76
+ return "\n".join(result)
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env python3
2
+ # bracket/VAR.py
3
+ # manage variables
4
+
5
+ # [VAR] [<var name>] [<value>] → <var name> = <value>
6
+ def VAR_to_varname_equal(code: str):
7
+ code = code.lstrip()
8
+ keyword, rest = code.split(" ", 1)
9
+ if keyword!="[VAR]":
10
+ raise SyntaxError(f"Expected `VAR` got `{keyword}`.")
11
+ inner = rest.removeprefix("[").removesuffix("]")
12
+ parts = inner.split("] [")
13
+ if len(parts) != 2:
14
+ raise SyntaxError("Usage: [VAR] [<var name>] [<value>]")
15
+ var_name = parts[0].strip()
16
+ value = parts[1].strip()
17
+ if not var_name:
18
+ raise SyntaxError("Var name cannot be empty.")
19
+ dangerous_list = ["INFO", "VAR", "INPUT", "IF", "ELSEIF", "ELSE", "FOR", "WHILE", "LOOP", "print", "input", "int", "float", "str", "def", "class", "exec", "import", "__import__"]
20
+ if not var_name.isidentifier():
21
+ raise SyntaxError(f"Invalid var name: {var_name}.")
22
+ if var_name in dangerous_list:
23
+ raise SyntaxError(f"Invalid var name: {var_name}.")
24
+ if not value:
25
+ raise SyntaxError("Value cannot be empty.")
26
+ return f"{var_name} = {value}"
27
+
28
+ def transpile_line(line: str) -> str:
29
+ """转译一行 bracket 代码,自动处理缩进"""
30
+ indent = len(line) - len(line.lstrip())
31
+ stripped = line.lstrip()
32
+ if not stripped:
33
+ return ""
34
+ if stripped.startswith("[VAR]"):
35
+ return " " * indent + VAR_to_varname_equal(stripped)
36
+ else:
37
+ return " " * indent + f"# UNKNOWN: {stripped}"
38
+
39
+ def transpile(code: str) -> str:
40
+ """转译多行 bracket 代码"""
41
+ lines = code.splitlines()
42
+ result = []
43
+ for line in lines:
44
+ result.append(transpile_line(line))
45
+ return "\n".join(result)
@@ -0,0 +1,5 @@
1
+ # bracket/__init__.py
2
+ from .transpile import transpile, transpile_line
3
+ from .cli import main
4
+
5
+ __all__ = ["transpile", "transpile_line", "main"]
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/python3
2
+ # bracket/bkted.py
3
+ # the editor of bracket-lang
4
+
5
+ import tkinter as tk
6
+ from tkinter import filedialog, scrolledtext, messagebox
7
+ from .transpile import transpile
8
+ import sys
9
+ from io import StringIO
10
+
11
+ class BracketEditor:
12
+ def __init__(self):
13
+ self.root = tk.Tk()
14
+ self.root.title("bkted - editor of btaracket")
15
+ self.root.geometry("800x600")
16
+
17
+ # Menu
18
+ menubar = tk.Menu(self.root)
19
+ file_menu = tk.Menu(menubar, tearoff=0)
20
+ file_menu.add_command(label="Open", command=self.open_file)
21
+ file_menu.add_command(label="Save", command=self.save_file)
22
+ file_menu.add_command(label="Transpile", command=self.show_transpile)
23
+ file_menu.add_command(label="Run", command=self.run_code)
24
+ menubar.add_cascade(label="File", menu=file_menu)
25
+ self.root.config(menu=menubar)
26
+
27
+ # Edit area
28
+ self.text = scrolledtext.ScrolledText(self.root, font=("Courier", 12))
29
+ self.text.pack(fill=tk.BOTH, expand=True)
30
+
31
+ def open_file(self):
32
+ path = filedialog.askopenfilename(filetypes=[("bracket file", "*.bracket")])
33
+ if path:
34
+ with open(path, "r", encoding="utf-8") as f:
35
+ self.text.delete("1.0", tk.END)
36
+ self.text.insert("1.0", f.read())
37
+
38
+ def save_file(self):
39
+ path = filedialog.asksaveasfilename(defaultextension=".bracket")
40
+ if path:
41
+ with open(path, "w", encoding="utf-8") as f:
42
+ f.write(self.text.get("1.0", tk.END))
43
+
44
+ def show_transpile(self):
45
+ """Transpile only and display the result"""
46
+ code = self.text.get("1.0", tk.END)
47
+ try:
48
+ py_code = transpile(code)
49
+ self._show_output("Transpile result", py_code)
50
+ except Exception as e:
51
+ import traceback
52
+ self._show_output("Transpile error", traceback.format_exc())
53
+
54
+ def run_code(self):
55
+ """Transpile and run"""
56
+ code = self.text.get("1.0", tk.END)
57
+ try:
58
+ py_code = transpile(code)
59
+
60
+ # Catch the output
61
+ old_stdout = sys.stdout
62
+ sys.stdout = StringIO()
63
+
64
+ # Run the transpiled code
65
+ exec(py_code, {})
66
+
67
+ output = sys.stdout.getvalue()
68
+ sys.stdout = old_stdout
69
+
70
+ # Display the running result
71
+ self._show_output("Running result", output or "[No output]")
72
+
73
+ except Exception as e:
74
+ import traceback
75
+ sys.stdout = old_stdout
76
+ self._show_output("Runtime error", traceback.format_exc())
77
+
78
+ def _show_output(self, title: str, content: str):
79
+ """Create a window and display the content"""
80
+ win = tk.Toplevel(self.root)
81
+ win.title(title)
82
+ win.geometry("600x400")
83
+ text = scrolledtext.ScrolledText(win, font=("Courier", 12))
84
+ text.pack(fill=tk.BOTH, expand=True)
85
+ text.insert("1.0", content)
86
+
87
+ def run(self):
88
+ self.root.mainloop()
89
+
90
+ if __name__ == "__main__":
91
+ editor = BracketEditor()
92
+ editor.run()
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env python3
2
+ # bracket/cli.py
3
+ # CLI entertainment of bracket-lang
4
+
5
+ import sys
6
+ import argparse
7
+ from .transpile import transpile
8
+
9
+ def main():
10
+ parser = argparse.ArgumentParser(
11
+ prog="bracket",
12
+ description="bracket-lang transpiler",
13
+ epilog="for example: bracket run main.bracket"
14
+ )
15
+ subparsers = parser.add_subparsers(dest="command", required=True)
16
+ # run command
17
+ run_parser = subparsers.add_parser("run", help="run .bracket file")
18
+ run_parser.add_argument("file", help="the .bracket file you want to run")
19
+ # build command
20
+ build_parser = subparsers.add_parser("build", help="transpile .bracket file to .py")
21
+ build_parser.add_argument("file", help="the .bracket file you want to transpile")
22
+ build_parser.add_argument("-o", "--output", help="output file name(default same name .py)")
23
+ args = parser.parse_args()
24
+ if args.command == "run":
25
+ with open(args.file, "r", encoding="utf-8") as f:
26
+ code = f.read()
27
+ py_code = transpile(code)
28
+ exec(py_code)
29
+ elif args.command == "build":
30
+ with open(args.file, "r", encoding="utf-8") as f:
31
+ code = f.read()
32
+ py_code = transpile(code)
33
+ output = args.output or args.file.replace(".bracket", ".py")
34
+ with open(output, "w", encoding="utf-8") as f:
35
+ f.write(py_code)
36
+ print(f"✓ transpile finished: {output}")
37
+
38
+ if __name__ == "__main__":
39
+ main()
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env python3
2
+ # bracket/transpile.py
3
+ # Unification transpile interface
4
+
5
+ import keyword
6
+
7
+ from .IO import INFO_to_print, INPUT_to_input
8
+ from .VAR import VAR_to_varname_equal
9
+ from .BRANCH import IF_to_if, ELSEIF_to_elif, ELSE_to_else
10
+ from .LOOP import (
11
+ FOR_to_for,
12
+ WHILE_to_while,
13
+ LOOP_to_while_True,
14
+ BREAK_to_break,
15
+ CONTINUE_to_continue,
16
+ )
17
+ from .IMPORTLIB import USE_to_import
18
+
19
+
20
+ def transpile_line(line: str) -> str:
21
+ indent = len(line) - len(line.lstrip())
22
+ stripped = line.lstrip().split("#")[0].rstrip()
23
+ if not stripped:
24
+ return ""
25
+ for i in keyword.kwlist:
26
+ if i in stripped:
27
+ raise SyntaxError("Sorry, we don't support python syntax.")
28
+ if stripped.startswith("[USE]"):
29
+ return " " * indent + USE_to_import(stripped)
30
+ elif stripped.startswith("[FOR]"):
31
+ return " " * indent + FOR_to_for(stripped)
32
+ elif stripped.startswith("[WHILE]"):
33
+ return " " * indent + WHILE_to_while(stripped)
34
+ elif stripped == "[LOOP]":
35
+ return " " * indent + LOOP_to_while_True(stripped)
36
+ elif stripped == "[BREAK]":
37
+ return " " * indent + BREAK_to_break(stripped)
38
+ elif stripped == "[CONTINUE]":
39
+ return " " * indent + CONTINUE_to_continue(stripped)
40
+ elif stripped.startswith("[IF]"):
41
+ return " " * indent + IF_to_if(stripped)
42
+ elif stripped.startswith("[ELSEIF]"):
43
+ return " " * indent + ELSEIF_to_elif(stripped)
44
+ elif stripped == "[ELSE]":
45
+ return " " * indent + ELSE_to_else(stripped)
46
+ elif "[INPUT]" in stripped:
47
+ return " " * indent + INPUT_to_input(stripped)
48
+ elif stripped.startswith("[VAR]"):
49
+ return " " * indent + VAR_to_varname_equal(stripped)
50
+ elif stripped.startswith("[INFO]"):
51
+ return " " * indent + INFO_to_print(stripped)
52
+ return " " * indent + line
53
+
54
+ def transpile(code: str) -> str:
55
+ lines = code.splitlines()
56
+ result = []
57
+ for line in lines:
58
+ if line.strip():
59
+ result.append(transpile_line(line))
60
+ else:
61
+ result.append("")
62
+ return "\n".join(result)
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: bracket-lang
3
+ Version: 0.1.0
4
+ Requires-Python: >=3.8
5
+ License-File: LICENSE
6
+ Dynamic: license-file
7
+ Dynamic: requires-python
@@ -0,0 +1,17 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ bracket/BRANCH.py
5
+ bracket/IMPORTLIB.py
6
+ bracket/IO.py
7
+ bracket/LOOP.py
8
+ bracket/VAR.py
9
+ bracket/__init__.py
10
+ bracket/bkted.py
11
+ bracket/cli.py
12
+ bracket/transpile.py
13
+ bracket_lang.egg-info/PKG-INFO
14
+ bracket_lang.egg-info/SOURCES.txt
15
+ bracket_lang.egg-info/dependency_links.txt
16
+ bracket_lang.egg-info/entry_points.txt
17
+ bracket_lang.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ bracket = bracket.cli:main
@@ -0,0 +1 @@
1
+ bracket
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,14 @@
1
+ # setup.py
2
+ from setuptools import setup, find_packages
3
+
4
+ setup(
5
+ name="bracket-lang",
6
+ version="0.1.0",
7
+ packages=find_packages(),
8
+ entry_points={
9
+ "console_scripts": [
10
+ "bracket = bracket.cli:main",
11
+ ],
12
+ },
13
+ python_requires=">=3.8",
14
+ )