mirror of
https://github.com/Open-Argon/Argon.git
synced 2026-10-28 09:43:38 +00:00
added edit items
This commit is contained in:
1 parent
57c122055e
commit
e92d1a29eb
3 files changed
+28
-14
No files matched your search
+26
-14
@@ -83,11 +83,13 @@ stringTextREGEX = r"( *)((((\')((\\([a-z\\\"\']))|[^\\\'])*(\'))|((\")((\\([a-z\
|
||||
numberTextREGEX = r"( *)([0-9]*(\.[0-9]*)?(e[0-9]+)?)( *)"
|
||||
varTextREGEX = r"( *)([a-z]|[A-Z])([a-zA-Z0-9]*)((\[.*\])*)( *)"
|
||||
bracketsTextREGEX = r"( *)\(.*\)( *)"
|
||||
commentTextREGEX = r'( *)\#(.*)( *)'
|
||||
functionTextREGEX = r"( *)(([a-z]|[A-Z])([a-zA-Z0-9]*))\(.*\)( *)"
|
||||
switchTextREGEX = r"( *).+\?.+\:.+( *)"
|
||||
itemsTextREGEX = r"( *)\[.*\]( *)"
|
||||
remTextREGEX = fr"( *)del( +)({varTextREGEX})( *)"
|
||||
cobined = fr"{stringTextREGEX}|{numberTextREGEX}|{varTextREGEX}|{functionTextREGEX}|{switchTextREGEX}|{itemsTextREGEX}"
|
||||
cobined = fr"{stringTextREGEX}|{numberTextREGEX}|{varTextREGEX}|{functionTextREGEX}|{switchTextREGEX}|{itemsTextREGEX}|{commentTextREGEX}"
|
||||
commentTest = re.compile(commentTextREGEX)
|
||||
cobinedcompiled = re.compile(cobined)
|
||||
bracketsTest = re.compile(bracketsTextREGEX)
|
||||
stringTest = re.compile(stringTextREGEX)
|
||||
@@ -125,7 +127,8 @@ def convert_backslash(string):
|
||||
# the mathermatical operators are +, -, *, /, %, **, //, and access boolian operators and their nots such as ==, !=, >, <, >=, <=, and in, not in
|
||||
def math_exec(operator, value1, value2):
|
||||
if operator == "+":
|
||||
return value1 + value2
|
||||
valtype = type(value1)
|
||||
return value1 + valtype(value2)
|
||||
elif operator == "-":
|
||||
return value1 - value2
|
||||
elif operator == "*":
|
||||
@@ -180,21 +183,25 @@ def val_Aexec(string, eval=False, vars=vars) -> Tuple[bool, any]: # returns a tu
|
||||
didprocess = False # did the string get processed
|
||||
output = None # the output of the string
|
||||
if not eval and setVar.fullmatch(string):
|
||||
stringsplit = string.split("=")
|
||||
if len(stringsplit) > 1:
|
||||
val = Aexec("=".join(stringsplit[1:]).strip(), True, vars=vars)
|
||||
if val[0]:
|
||||
value = val[1]
|
||||
else:
|
||||
raise Exception(f"Error in assignment: {val[1]}")
|
||||
else:
|
||||
value = None
|
||||
typeAndVar = re.split(r"( +)", stringsplit[0])
|
||||
varname = typeAndVar[2]
|
||||
typeAndVar = re.split(r"( +)", string)
|
||||
varname = []
|
||||
aftertype = "".join(typeAndVar[2:])
|
||||
value = None
|
||||
type = typeAndVar[0]
|
||||
if varname == "" and type not in ["const", "var"]:
|
||||
if type not in ["const", "var"]:
|
||||
varname = type
|
||||
type = "var"
|
||||
for i in range(len(aftertype)):
|
||||
char = aftertype[i]
|
||||
joined = "".join(varname)
|
||||
if i == len(aftertype)-1 and varTest.fullmatch(joined):
|
||||
varname = joined.strip()
|
||||
break
|
||||
elif char == "=" and varTest.fullmatch(joined):
|
||||
value = Aexec(aftertype[len(joined)+1:], eval=True,vars=vars)[1]
|
||||
varname = joined.strip()
|
||||
break
|
||||
varname.append(char)
|
||||
if varname in vars:
|
||||
if vars[varname]["type"] == "init":
|
||||
raise Exception(f'Variable {varname} is an initialized variable')
|
||||
@@ -244,6 +251,8 @@ def val_Aexec(string, eval=False, vars=vars) -> Tuple[bool, any]: # returns a tu
|
||||
elif numberTest.fullmatch(string):
|
||||
didprocess = True
|
||||
output = number(string)
|
||||
elif commentTest.fullmatch(string):
|
||||
pass
|
||||
elif varTest.fullmatch(string):
|
||||
didprocess = True
|
||||
bracketSplit = string.strip().split("[")
|
||||
@@ -498,8 +507,11 @@ if __name__ == "__main__":
|
||||
print(boxify(
|
||||
version+'\nMIT LICENCE AGREEMENT\n(https://github.com/Ugric/Argon)', align='center'))
|
||||
while True:
|
||||
try:
|
||||
code = input(">>> ")
|
||||
if code != "":
|
||||
output = (Aexec(code))
|
||||
if output[0]:
|
||||
log(output[1])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
Vendored
BIN
Binary file not shown.
Reference in new issue
Block a user