Skip to content

Commit

Permalink
rename "whatif" function to "condition" function
Browse files Browse the repository at this point in the history
  • Loading branch information
kokonut27 committed Nov 19, 2023
1 parent 44362f4 commit fb3ac35
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 58 deletions.
2 changes: 1 addition & 1 deletion examples/fibonacci.zsq
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function Fibonacci(num) {
whatif num <= 1 {
condition num <= 1 {
return(num)
}
else {
Expand Down
2 changes: 1 addition & 1 deletion tests/index.zsq
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ print(^"{hi}")

os.system("clear")

whatif variable != true {
condition variable == false {
print("hello")
}

Expand Down
116 changes: 60 additions & 56 deletions zsq/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import pymongo
from info import *

'''
try:
os.system('pip install dnspython')
except:
print("could not download dnspython - try again later")
exit()
'''


red = "\033[0;91m"
Expand Down Expand Up @@ -45,6 +47,7 @@ class nonzsqfile(Exception):
pass


'''
# db :pensive:
class database():
def __init__(self):
Expand All @@ -68,6 +71,7 @@ def insert_in(self, item_name, *content):
self.collection.insert_one(content)
return
'''


@click.command()
Expand Down Expand Up @@ -95,7 +99,7 @@ def check():


allvars = {}
what_if = {}
condition = {}
all_packages = ["os", "time", "math", "color"]
correct_syntax = False
line = 0
Expand Down Expand Up @@ -597,8 +601,8 @@ def Print():
elif "print(" in lines:
Print()

elif "whatif " in lines:
wrd = "whatif "
elif "condition " in lines:
wrd = "condition "
res = lines.partition(wrd)[2]
symbols = ["!=", "==", "isin", ">=", "<=", ">", "<"]

Expand All @@ -625,57 +629,59 @@ def Print():
vale = vale.replace(" ", "")
vale = vale.replace("{", "")
if vale == "true":
print("EAEA")
# vale = True

if var == "true":
what_if[vare] = False
else:
what_if[vare] = True
condition[vare] = False
elif var == "false":
condition[vare] = True
elif "false" in vale:
vale = vale.replace(" ", "")
vale = vale.replace("{", "")
if vale == "false":
# vale = True
print("AEAE")

if var == "false":
what_if[vare] = False
else:
what_if[vare] = True
condition[vare] = False
elif var == "true":
condition[vare] = True
# elif "string" in vale:
elif "bool" in vale:
vale = vale.replace(" ", "")
vale = vale.replace("{", "")

if vale == "bool":
if var == "true" or var == "false":
what_if[vare] = False
condition[vare] = False
else:
what_if[vare] = True
condition[vare] = True
elif "integer" in vale:
vale = vale.replace(" ", "")
vale = vale.replace("{", "")

if vale == "integer":
if var == int:
what_if[vare] = False
condition[vare] = False
else:
what_if[vare] = True
condition[vare] = True

elif "float" in vale:
vale = vale.replace(" ", "")
vale = vale.replace("{", "")

if vale == "float":
if var == float:
what_if[vare] = False
condition[vare] = False
else:
what_if[vare] = True
condition[vare] = True

elif 1 in vale or 2 in vale or 3 in vale or 4 in vale or 5 in vale or 6 in vale or 7 in vale or 8 in vale or 9 in vale or 0 in vale:
if var != vale:
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

else:
error(f"'{vale}' is undefined!")
Expand All @@ -694,9 +700,9 @@ def Print():
vale = vale.replace('\\"', "")

if var == str(vale):
what_if[vare] = False
condition[vare] = False
else:
what_if[vare] = True
condition[vare] = True

else:
vale = vale[e+1:]
Expand All @@ -711,9 +717,9 @@ def Print():
vale = vale.replace('\\"', "")

if var == str(vale):
what_if[vare] = False
condition[vare] = False
else:
what_if[vare] = True
condition[vare] = True

continue

Expand Down Expand Up @@ -744,54 +750,54 @@ def Print():
# vale = True

if var == "true":
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False
elif "false" in vale:
vale = vale.replace(" ", "")
vale = vale.replace("{", "")
if vale == "false":
# vale = True

if var == "false":
what_if[vare] = False
condition[vare] = False
else:
what_if[vare] = True
condition[vare] = True
# elif "string" in vale:
elif "bool" in vale:
vale = vale.replace(" ", "")
vale = vale.replace("{", "")

if vale == "bool":
if var == "true" or var == "false":
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False
elif "integer" in vale:
vale = vale.replace(" ", "")
vale = vale.replace("{", "")

if vale == "integer":
if var == int:
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

elif "float" in vale:
vale = vale.replace(" ", "")
vale = vale.replace("{", "")

if vale == "float":
if var == float:
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

elif 1 in vale or 2 in vale or 3 in vale or 4 in vale or 5 in vale or 6 in vale or 7 in vale or 8 in vale or 9 in vale or 0 in vale:
if var == vale:
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

else:
error(f"'{vale}' is undefined!")
Expand All @@ -810,9 +816,9 @@ def Print():
vale = vale.replace('\\"', "")

if var == str(vale):
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

else:
vale = vale[e+1:]
Expand All @@ -827,9 +833,9 @@ def Print():
vale = vale.replace('\\"', "")

if var == str(vale):
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

continue

Expand Down Expand Up @@ -890,9 +896,9 @@ def Print():

elif 1 in vale or 2 in vale or 3 in vale or 4 in vale or 5 in vale or 6 in vale or 7 in vale or 8 in vale or 9 in vale or 0 in vale:
if var in vale:
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

else:
error(f"'{vale}' is undefined!")
Expand All @@ -911,9 +917,9 @@ def Print():
vale = vale.replace('\\"', "")

if var in str(vale):
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

else:
vale = vale[e+1:]
Expand All @@ -928,9 +934,9 @@ def Print():
vale = vale.replace('\\"', "")

if var in str(vale):
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

continue

Expand Down Expand Up @@ -991,9 +997,9 @@ def Print():

elif 1 in vale or 2 in vale or 3 in vale or 4 in vale or 5 in vale or 6 in vale or 7 in vale or 8 in vale or 9 in vale or 0 in vale:
if var >= vale:
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

else:
error(f"'{vale}' is undefined!")
Expand Down Expand Up @@ -1090,9 +1096,9 @@ def Print():

elif 1 in vale or 2 in vale or 3 in vale or 4 in vale or 5 in vale or 6 in vale or 7 in vale or 8 in vale or 9 in vale or 0 in vale:
if var <= vale:
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

else:
error(f"'{vale}' is undefined!")
Expand Down Expand Up @@ -1189,9 +1195,9 @@ def Print():

elif 1 in vale or 2 in vale or 3 in vale or 4 in vale or 5 in vale or 6 in vale or 7 in vale or 8 in vale or 9 in vale or 0 in vale:
if var < vale:
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

else:
error(f"'{vale}' is undefined!")
Expand Down Expand Up @@ -1289,9 +1295,9 @@ def Print():

elif 1 in vale or 2 in vale or 3 in vale or 4 in vale or 5 in vale or 6 in vale or 7 in vale or 8 in vale or 9 in vale or 0 in vale:
if var > vale:
what_if[vare] = True
condition[vare] = True
else:
what_if[vare] = False
condition[vare] = False

else:
error(f"'{vale}' is undefined!")
Expand Down Expand Up @@ -1330,12 +1336,12 @@ def Print():
continue

else:
error("'whatif' statement must have an operator!")
error("'condition' statement must have an operator!")
exit()

elif lines:
"""
if what_if[vare] == True:
if condition[vare] == True:
pass
else:
continue
Expand All @@ -1352,7 +1358,7 @@ def Print():
res = lines.partition(wrd)[2]
symbols = ["!=", "==", "isin", ">=", "<=", ">", "<"]
else:
error("'whatif' statement must have an ending '}'!")
error("'condition' statement must have an ending '}'!")
exit()


Expand Down Expand Up @@ -1419,7 +1425,5 @@ def Print():

if __name__ == "__main__":
#db = database()



filepath()

0 comments on commit fb3ac35

Please sign in to comment.