From 4bb3864d201a398d5aeebf0ebcbd24797ad6cdf4 Mon Sep 17 00:00:00 2001 From: justuswolff Date: Fri, 10 May 2024 22:43:32 +0200 Subject: [PATCH] new file: HASHBASE/console-utils/log.py new file: HASHBASE/operators/add.py new file: HASHBASE/operators/divide.py new file: HASHBASE/operators/equal.py new file: HASHBASE/operators/higher.py new file: HASHBASE/operators/lower.py new file: HASHBASE/operators/multiply.py new file: HASHBASE/operators/remainder.py new file: HASHBASE/operators/subtract.py new file: HASHBASE/statements/create.py new file: HASHBASE/statements/getatt.py new file: HASHBASE/statements/if.py new file: HASHBASE/statements/newobj.py new file: HASHBASE/statements/setatt.py modified: PCPL/interpreter.py modified: hashengine.py deleted: langsys/__pycache__/__init__.cpython-311.pyc modified: langsys/lang/de_DE.LAN modified: langsys/lang/en_EN.LAN modified: main.py --- HASHBASE/console-utils/log.py | 27 ++++++++++++ HASHBASE/operators/add.py | 18 ++++++++ HASHBASE/operators/divide.py | 18 ++++++++ HASHBASE/operators/equal.py | 18 ++++++++ HASHBASE/operators/higher.py | 21 ++++++++++ HASHBASE/operators/lower.py | 21 ++++++++++ HASHBASE/operators/multiply.py | 18 ++++++++ HASHBASE/operators/remainder.py | 18 ++++++++ HASHBASE/operators/subtract.py | 16 ++++++++ HASHBASE/statements/create.py | 41 +++++++++++++++++++ HASHBASE/statements/getatt.py | 18 ++++++++ HASHBASE/statements/if.py | 23 +++++++++++ HASHBASE/statements/newobj.py | 20 +++++++++ HASHBASE/statements/setatt.py | 19 +++++++++ PCPL/interpreter.py | 4 +- hashengine.py | 1 - langsys/__pycache__/__init__.cpython-311.pyc | Bin 2596 -> 0 bytes langsys/lang/de_DE.LAN | 3 ++ langsys/lang/en_EN.LAN | 3 ++ main.py | 28 +++++++++++++ 20 files changed, 331 insertions(+), 4 deletions(-) create mode 100644 HASHBASE/console-utils/log.py create mode 100644 HASHBASE/operators/add.py create mode 100644 HASHBASE/operators/divide.py create mode 100644 HASHBASE/operators/equal.py create mode 100644 HASHBASE/operators/higher.py create mode 100644 HASHBASE/operators/lower.py create mode 100644 HASHBASE/operators/multiply.py create mode 100644 HASHBASE/operators/remainder.py create mode 100644 HASHBASE/operators/subtract.py create mode 100644 HASHBASE/statements/create.py create mode 100644 HASHBASE/statements/getatt.py create mode 100644 HASHBASE/statements/if.py create mode 100644 HASHBASE/statements/newobj.py create mode 100644 HASHBASE/statements/setatt.py delete mode 100644 langsys/__pycache__/__init__.cpython-311.pyc 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 833724b5e86595ff64ed6d7373351ff3d218b31f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2596 zcmb^yO-~zF@U3_Kf$hW)Oq|$m;}#NQ0wm2x4^e_b>pp5EnsjA>@G<# zj*8SAXl1E1Lc)!x;zODyiYn!hLy!FlUbIrsN=TJ@%FPw6ROQr}x2!*ssOq6_VcvYa zdGqmR#y=f6;3lxP-|e3|ClK;G64nBmt-aH*Z4yc-mnGxo&W&?6GEAuLHlh3j8zGP3 z-(2H1%8ihi@EpnHU;xpAHfx5>Cb?Evl60nkC6a8rxn z$)a)_u- zi%-a`6*y7xzWp_8x3F>p*WwYP9<1XJz{=yACCcSN)Xa;M&+p&j3w+sC*Q#UG)_j`s zM{7bV%rUR!uhjM$^Z)YHj-D2Hgw)aetha=MP-ewaw`yV!V0&C+-V)S6jUcmL3oi)G zG2wj$GFy9r|C|eFJr@_@^5Tzb$g%;xH{954k2>eri^w7Mjrw`&YCgpg+Cp10P&akY zXbaj=kJYsrrRCN-zm7HMq}c{-hyZG^&C;R-irt;e+fQM+zu@|xqr(Od^`3Vy-YJ8V zWz1N3TYA@L7=B z7vxM1j^dq$Fefc5hMn1p*$qLFvQvhab!%#LC^eRh8{W|?pNu9gipv-R+ElQ$BDh{8 zCNE5kDUz&Ad^9#R5*ZmyL`JT>pGw9DKmK$gE-7>B{KCXcTA7(y`hx9JZaR~b`p!&X z%*wJdA&Qw?Mis^Wg=LJ%B=UX~?@y3^i;I1(1R=?*WGB$MCKSEacK8TTp53&n-KVxcrx{IYy} z+ZV0)qPv06D_6{D;elTkweaO%JGH=&9vE5|b^@Wz4t)Ok%-)h z45uQg_#pZA#%I}QcEAbc004NE4txjZhYq2pNAHWE_Pu24>}jyV;Z#hoV9^ zP3I3aC57>hfR-{00CM7MFXl_5Tc1^Y-SGFs|1@0bxdi369^bfH7Vf)s|H+CE|DMF3 zCMtcGQDLQYZtH^XJ5gTLeX)uwW@fXNBe)oQfn_rZ$R<%6WQ~!R8%qIBn(N=Dos|h* z#xZSXA`BSR2o{HehW5+CHEouK(%h~V7fVV(omH~yYsYY(`Mb9LU7G)d?mwaVqB=C3 zE6QR^LXL5&m^0CdlK`h2OgFbEUYn;&Y|?o}ad9b~H6?Nvo{u5uMbHo65n;Ens+BQC z3}Bv=F#xNzuWIwz->H&j@HS^ZS|v5$;O#wCQUh+z-i^|ifoTzq#dz6=Hu3k=w0;IL z>;&e~3)e+6lmYoH@Gz6ghXATP$8kHPWtDw9#J$SCsx8EUu~)$#$oum(0%qzT#k&oM 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