diff --git a/HASHBASE/console-utils/log.py b/HASHBASE/console-utils/log.py new file mode 100644 index 0000000..5807763 --- /dev/null +++ b/HASHBASE/console-utils/log.py @@ -0,0 +1,27 @@ +class main(): + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + end = "\n" + flush = False + text = "" + if len(params) > 0: + text = params[0] + if len(params) > 1: + end = params[1] + if len(params) > 2: + flush = bool(params[2]) + if len(params) > 3: + return (1) + print(text, end=end, flush=flush) + return (0, None) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + print("Operations are not supported with this instruction") + return (1) diff --git a/HASHBASE/operators/add.py b/HASHBASE/operators/add.py new file mode 100644 index 0000000..b4db1d1 --- /dev/null +++ b/HASHBASE/operators/add.py @@ -0,0 +1,18 @@ +class main(): + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + if arg1.isnumeric() and arg2.isnumeric(): + return (0, int(arg1)+int(arg2)) + else: + return (0, arg1+arg2) \ No newline at end of file diff --git a/HASHBASE/operators/divide.py b/HASHBASE/operators/divide.py new file mode 100644 index 0000000..af8b3a3 --- /dev/null +++ b/HASHBASE/operators/divide.py @@ -0,0 +1,18 @@ +class main(): + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + if arg1.isnumeric() and arg2.isnumeric(): + return (0, int(arg1)/int(arg2)) + else: + return (1) \ No newline at end of file diff --git a/HASHBASE/operators/equal.py b/HASHBASE/operators/equal.py new file mode 100644 index 0000000..bdc659b --- /dev/null +++ b/HASHBASE/operators/equal.py @@ -0,0 +1,18 @@ +class main(): + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + if str(arg1) == str(arg2): + return (0, True) + else: + return (0, False) \ No newline at end of file diff --git a/HASHBASE/operators/higher.py b/HASHBASE/operators/higher.py new file mode 100644 index 0000000..d2485ee --- /dev/null +++ b/HASHBASE/operators/higher.py @@ -0,0 +1,21 @@ +class main(): + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + if arg1.isnumeric() and arg2.isnumeric(): + if arg1 > arg2: + return (0, True) + else: + return (0, False) + else: + return (1) diff --git a/HASHBASE/operators/lower.py b/HASHBASE/operators/lower.py new file mode 100644 index 0000000..a3ca0d1 --- /dev/null +++ b/HASHBASE/operators/lower.py @@ -0,0 +1,21 @@ +class main(): + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + if arg1.isnumeric() and arg2.isnumeric(): + if arg1 < arg2: + return (0, True) + else: + return (0, False) + else: + return (1) \ No newline at end of file diff --git a/HASHBASE/operators/multiply.py b/HASHBASE/operators/multiply.py new file mode 100644 index 0000000..6834b46 --- /dev/null +++ b/HASHBASE/operators/multiply.py @@ -0,0 +1,18 @@ +class main(): + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + if arg1.isnumeric() and arg2.isnumeric(): + return (0, int(arg1)*int(arg2)) + else: + return (0, arg1*arg2) \ No newline at end of file diff --git a/HASHBASE/operators/remainder.py b/HASHBASE/operators/remainder.py new file mode 100644 index 0000000..0b349a0 --- /dev/null +++ b/HASHBASE/operators/remainder.py @@ -0,0 +1,18 @@ +class main(): + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + if arg1.isnumeric() and arg2.isnumeric(): + return (0, int(arg1)%int(arg2)) + else: + return (1) \ No newline at end of file diff --git a/HASHBASE/operators/subtract.py b/HASHBASE/operators/subtract.py new file mode 100644 index 0000000..6ad02c4 --- /dev/null +++ b/HASHBASE/operators/subtract.py @@ -0,0 +1,16 @@ +class main(): + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + if arg1.isnumeric() and arg2.isnumeric(): + return (0, int(arg1)-int(arg2)) \ No newline at end of file diff --git a/HASHBASE/statements/create.py b/HASHBASE/statements/create.py new file mode 100644 index 0000000..71107b3 --- /dev/null +++ b/HASHBASE/statements/create.py @@ -0,0 +1,41 @@ +class main(): + def __init__(self, interpreter): + self.interpreter = interpreter + + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + class temp(): + def __init__(self, interpreter): + self.interpreter = interpreter + self.CS = "" + self.STRtypes = ['"', "<", "{", "[", "(", ":"] + self.ENDtypes = ['"', ">", "}", "]", ")", ";"] + def IND(self, index): + return (0, self.CS[index]) + def EXEC(self, params): + PREPEDAST = self.interpreter.lexer.tokenGEN(self.CS, self.STRtypes, self.ENDtypes) + PREPEDAST = self.interpreter.PREPAST(PREPEDAST) + PREPEDAST = self.interpreter.EXECINS(PREPEDAST) + return (0, PREPEDAST) + def ATR(self, target): + return (0, self.CS) + def STAT(self, params): + self.CS = params[0] + return (0, None) + def OP(self, arg1, arg2): + print("Operations are not supported with this CI") + return (1) + tempC = temp(self.interpreter) + self.interpreter.vars[params[0]] = tempC + return (0, None) + def OP(self, arg1, arg2): + print("Operations are not supported with this instruction") + return (1) diff --git a/HASHBASE/statements/getatt.py b/HASHBASE/statements/getatt.py new file mode 100644 index 0000000..752f068 --- /dev/null +++ b/HASHBASE/statements/getatt.py @@ -0,0 +1,18 @@ +class main(): + def __init__(self, interpreter): + self.interpreter = interpreter + + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + return (0, getattr(self.interpreter.vars[target[0]], target[1])) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + print("Operations are not supported with this instruction") + return (1) diff --git a/HASHBASE/statements/if.py b/HASHBASE/statements/if.py new file mode 100644 index 0000000..19235ae --- /dev/null +++ b/HASHBASE/statements/if.py @@ -0,0 +1,23 @@ +class main(): + def __init__(self, interpreter): + self.interpreter = interpreter + + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + if str(params[1]) == "True": + if params[0] in self.interpreter.instructions: + self.interpreter.instructions[params[0]].EXEC([]) + elif params[0] in self.interpreter.vars: + self.interpreter.vars[params[0]].EXEC([]) + return (0, None) + def OP(self, arg1, arg2): + print("Operations are not supported with this instruction") + return (1) diff --git a/HASHBASE/statements/newobj.py b/HASHBASE/statements/newobj.py new file mode 100644 index 0000000..5573454 --- /dev/null +++ b/HASHBASE/statements/newobj.py @@ -0,0 +1,20 @@ +class main(): + def __init__(self, interpreter): + self.interpreter = interpreter + + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + print("Getting an attribute is not supported with this instruction") + return (1) + def STAT(self, params): + object = self.interpreter.ENG.object() + self.interpreter.vars[params[0]] = object + return (0, None) + def OP(self, arg1, arg2): + print("Operations are not supported with this instruction") + return (1) diff --git a/HASHBASE/statements/setatt.py b/HASHBASE/statements/setatt.py new file mode 100644 index 0000000..a9ff387 --- /dev/null +++ b/HASHBASE/statements/setatt.py @@ -0,0 +1,19 @@ +class main(): + def __init__(self, interpreter): + self.interpreter = interpreter + + def IND(self, index): + print("Indexing is not supported with this instruction") + return (1) + def EXEC(self, params): + print("Execution is not supported with this instruction") + return (1) + def ATR(self, target): + setattr(self.interpreter.vars[target[0]], target[1], target[2]) + return (0, None) + def STAT(self, params): + print("Statements are not supported with this instruction") + return (1) + def OP(self, arg1, arg2): + print("Operations are not supported with this instruction") + return (1) diff --git a/PCPL/interpreter.py b/PCPL/interpreter.py index de740d7..0417d51 100644 --- a/PCPL/interpreter.py +++ b/PCPL/interpreter.py @@ -14,9 +14,7 @@ class interpreter(): def INDEXING(self, target): target = target[1:] target = target[:-1] - target = target.split(",") - for i in range(len(target)): - target[i] = target[i].replace(".", ",") + target = target.split("\,") if target[0] in self.instructions: return self.instructions[target[0]].IND(target[1]) elif target[0] in self.vars: diff --git a/hashengine.py b/hashengine.py index 75ff445..48b7a1a 100644 --- a/hashengine.py +++ b/hashengine.py @@ -120,7 +120,6 @@ class obj: self.position = vector2() self.char = " " self.ID = 0 - self.parent = None self.gravity = 0 self.acceleration = vector2() self.velocity = vector2() diff --git a/langsys/__pycache__/__init__.cpython-311.pyc b/langsys/__pycache__/__init__.cpython-311.pyc deleted file mode 100644 index 833724b..0000000 Binary files a/langsys/__pycache__/__init__.cpython-311.pyc and /dev/null differ diff --git a/langsys/lang/de_DE.LAN b/langsys/lang/de_DE.LAN index 88e332f..bd1b397 100644 --- a/langsys/lang/de_DE.LAN +++ b/langsys/lang/de_DE.LAN @@ -4,4 +4,7 @@ "open": "Oeffnen", "exit": "Beenden", "langs": "Sprachen", +"add": "Erstellen", +"obj": "Objekt", +"script": "Skript", } \ No newline at end of file diff --git a/langsys/lang/en_EN.LAN b/langsys/lang/en_EN.LAN index 6c1a320..09fad92 100644 --- a/langsys/lang/en_EN.LAN +++ b/langsys/lang/en_EN.LAN @@ -4,4 +4,7 @@ "open": "Open", "exit": "Quit", "langs": "Languages", +"add": "Create", +"obj": "Object", +"script": "Script", } \ No newline at end of file diff --git a/main.py b/main.py index 8e49eeb..41a49eb 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,6 @@ +import sys + +sys.dont_write_bytecode = True import mtTkinter as tk from tkinter import ttk as tkk import PCPL @@ -8,12 +11,25 @@ import sys import hashengine global LH +global gamedata +gamedata = [] LH = langsys.langhandler() lang = open("clang", 'r') lang = lang.read() LH.setlang(lang) # LH.string("") +PCPL.interpreter.ENG = hashengine + +class script: + def __init__(self): + self.code = "" + + def execute(self): + PCPL.resetvar() + PCPL.LIS("HASHBASE") + PCPL.run(self.code) + class preview: def __init__(self, size, container, offset): self._size = size @@ -48,6 +64,11 @@ def selectlang(new): container.quit() subprocess.Popen([sys.executable, __file__]) +def add(objtype): + obj = dir(types)[objtype]() + temp = {"id": objtype, "args": dir(obj)} + gamedata.append(temp()) + def GUIinit(): global container container = tk.Tk() @@ -66,6 +87,10 @@ def GUIinit(): filemenu.add_separator() filemenu.add_command(label=LH.string("exit"), command=container.quit) + addmenu = tk.Menu(menu) + menu.add_cascade(label=LH.string("add"), menu=addmenu) + filemenu.add_command(label=LH.string("obj"), command=lambda: add("obj")) + langmenu = tk.Menu(menu) menu.add_cascade(label=LH.string("langs"), menu=langmenu) for i in LH.getlangs(): @@ -73,4 +98,7 @@ def GUIinit(): container.mainloop() +global types +types = hashengine.enum({"obj": hashengine.obj, "script": script}) + GUIinit() \ No newline at end of file