-
Notifications
You must be signed in to change notification settings - Fork 0
/
GCScript.py
161 lines (141 loc) · 5.11 KB
/
GCScript.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/python3
#Build in Ubuntu 20.04
#This is a little Demo
import zipfile
import os
import math
import tkinter
import time
import sys
import random
def readfile(file):
try:
files = open(file+".gc")
line = files.readline()
while line:
scripts(line)
line = files.readline()
files.close()
except:
print("faild to open file "+file+".gc")
files.close()
def sys_init_start(DE=False, GU=False, NE=True):
DEBUG = DE
GUI = GU
NEW = NE
#settings
global read_sct
global ids
DEBUG = False
VER = "0.0.1"
KEYWORDS = ["when", "if", "outprint", "SaveAndQuit", "using", "setv", "/", "help", "get_input", "pause"]
VLAUETYPES = ["string", "int", "float", "boolen", "bin"]
value_branches = {0:"string", 1:"int", 2:"float", 3:"boolen", 4:"bin"}
helps = None
users_value = {}
#settings
def help_system(help_things=None):
try:
files = open("help.txt")
line = files.readline()
while line:
print(line)
line = files.readline()
files.close()
except:
print("faild to open helpfile")
files.close()
def branch(types=None, types2=None):
global read_sct
global ids
ids = 0
if types2 == None:
for script_text in read_sct:
if types in script_text:ids += 1
elif types2 != None:
for script_text in read_sct:
if types in script_text or types2 in script_text:ids += 1
else:
return None
def sys_exit_code(mode=False):
if mode == True:
pass
def scripts(script=None):
global ids
if script == None:return None
else:
global read_sct
read_sct = script
for keywords in KEYWORDS:
if keywords in script:
if keywords == "pause":
branch("(", ")")
if ids == 2:
try:
time.sleep(int(script[6:len(script)-1]))
except:
print("faild:None")
else:print("faild:missing ( or )")
if keywords == "get_input":
branch('"', '"')
if ids == 2:
ipt = input(script[11:len(script)-1])
print("INPUT:"+str(ipt))
else:print('faild:missing "')
if keywords == "using":
branch("(", ")")
if ids == 2:
readfile(script[6:len(script)-1])
else:print("faild:missing ( or )")
if keywords == "help":
branch('(', ')')
if ids == 2:help_system()
else:print("faild:missing ( or )")
if keywords == "outprint":
branch('"')
if ids == 2:
if DEBUG == True:print("DEBUG:"+script[9:len(script)])
else:print("OUTPUT:"+script[9:len(script)])
else:
print('faild:missing " ')
print("FAILD")
if keywords == "SaveAndQuit":
branch('(', ')')
if ids == 2:
print("exit with code 0")
sys.exit()
else:print("faild:missing ( or )")
if keywords == "setv":
branch('[', ']')
if ids == 2:
value_branch = 0
for _ in range(5):
if script[5:len(script)-1] == value_branches[value_branch]:
print(value_branches[value_branch])
name = input("input for your value name:")
for u_values in users_value:
if name in u_values:
print(users_value[name])
break
else:
users_value.update(name)
break
else:
if value_branch < 4:
value_branch += 1
else:print("faild:can't find value type "+script[5:len(script)-1])
else:
print("faild:missing [ or ]")
print("FAILD")
for u_values in users_value:
if script == u_values:
print(users_value[script])
break
else:
pass
print("GCScript v0.01")
print("using help() to get more imformation")
while True:
sys_exit_code(mode=True)
ream = input(">>>")
scripts(ream)