easycoder 241218.1__py2.py3-none-any.whl → 241231.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of easycoder might be problematic. Click here for more details.
- easycoder/README.md +6 -0
- easycoder/__init__.py +2 -2
- easycoder/ec.py +10 -0
- easycoder/ec_classes.py +3 -0
- easycoder/ec_compiler.py +7 -6
- easycoder/ec_core.py +29 -4
- easycoder/ec_graphics.py +275 -222
- easycoder/ec_handler.py +1 -0
- easycoder/ec_program.py +72 -58
- easycoder/ec_renderer.py +235 -325
- easycoder/ec_screenspec.py +77 -0
- easycoder/ec_value.py +10 -10
- {easycoder-241218.1.dist-info → easycoder-241231.1.dist-info}/METADATA +11 -3
- easycoder-241231.1.dist-info/RECORD +19 -0
- easycoder-241218.1.dist-info/RECORD +0 -16
- {easycoder-241218.1.dist-info → easycoder-241231.1.dist-info}/LICENSE +0 -0
- {easycoder-241218.1.dist-info → easycoder-241231.1.dist-info}/WHEEL +0 -0
- {easycoder-241218.1.dist-info → easycoder-241231.1.dist-info}/entry_points.txt +0 -0
easycoder/ec_program.py
CHANGED
|
@@ -11,23 +11,18 @@ class Program:
|
|
|
11
11
|
|
|
12
12
|
def __init__(self, argv):
|
|
13
13
|
print(f'EasyCoder version {version("easycoder")}')
|
|
14
|
-
scriptName = None
|
|
15
14
|
if len(argv) == 0:
|
|
16
15
|
print('No script supplied')
|
|
17
16
|
exit()
|
|
18
17
|
self.classes=[Core]
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
self.classes.append(Graphics)
|
|
24
|
-
else:
|
|
25
|
-
scriptName = arg
|
|
18
|
+
scriptName = argv[0]
|
|
19
|
+
if scriptName.endswith('.ecg'):
|
|
20
|
+
from .ec_graphics import Graphics
|
|
21
|
+
self.classes.append(Graphics)
|
|
26
22
|
|
|
27
23
|
f = open(scriptName, 'r')
|
|
28
24
|
source = f.read()
|
|
29
25
|
f.close()
|
|
30
|
-
self.argv = argv
|
|
31
26
|
self.domains = []
|
|
32
27
|
self.domainIndex = {}
|
|
33
28
|
self.name = '<anon>'
|
|
@@ -43,6 +38,8 @@ class Program:
|
|
|
43
38
|
self.condition = self.compiler.condition
|
|
44
39
|
self.processClasses()
|
|
45
40
|
self.queue = deque()
|
|
41
|
+
self.externalControl = False
|
|
42
|
+
self.quit = False
|
|
46
43
|
|
|
47
44
|
def start(self):
|
|
48
45
|
startCompile = time.time()
|
|
@@ -203,57 +200,72 @@ class Program:
|
|
|
203
200
|
|
|
204
201
|
# Tokenise the script
|
|
205
202
|
def tokenise(self, script):
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
for
|
|
203
|
+
token = ''
|
|
204
|
+
literal = False
|
|
205
|
+
for lino in range(0, len(script.lines)):
|
|
206
|
+
line = script.lines[lino]
|
|
209
207
|
length = len(line)
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
if length == 0:
|
|
209
|
+
continue
|
|
210
|
+
# Look for the first non-space
|
|
212
211
|
n = 0
|
|
213
|
-
while n < length:
|
|
212
|
+
while n < length and line[n].isspace():
|
|
213
|
+
n += 1
|
|
214
|
+
# The whole line may be empty
|
|
215
|
+
if n == length:
|
|
216
|
+
if literal:
|
|
217
|
+
token += '\n'
|
|
218
|
+
continue
|
|
219
|
+
# If in an unfinished literal, the first char must be a backtick to continue adding to it
|
|
220
|
+
if literal:
|
|
221
|
+
if line[n] != '`':
|
|
222
|
+
# Close the current token
|
|
223
|
+
if len(token) > 0:
|
|
224
|
+
script.tokens.append(Token(lino, token))
|
|
225
|
+
token = ''
|
|
226
|
+
literal = False
|
|
227
|
+
n += 1
|
|
228
|
+
for n in range(n, length):
|
|
214
229
|
c = line[n]
|
|
215
|
-
if
|
|
216
|
-
|
|
217
|
-
|
|
230
|
+
# Test if we are in a literal
|
|
231
|
+
if not literal:
|
|
232
|
+
if c.isspace():
|
|
233
|
+
if len(token) > 0:
|
|
234
|
+
script.tokens.append(Token(lino, token))
|
|
235
|
+
token = ''
|
|
218
236
|
continue
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
inSpace = True
|
|
223
|
-
n += 1
|
|
224
|
-
continue
|
|
225
|
-
inSpace = False
|
|
237
|
+
elif c == '!':
|
|
238
|
+
break
|
|
239
|
+
# Test for the start or end of a literal
|
|
226
240
|
if c == '`':
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
elif c == '!':
|
|
236
|
-
break
|
|
241
|
+
if literal:
|
|
242
|
+
token += c
|
|
243
|
+
literal = False
|
|
244
|
+
else:
|
|
245
|
+
token += c
|
|
246
|
+
literal = True
|
|
247
|
+
m = n
|
|
248
|
+
continue
|
|
237
249
|
else:
|
|
238
250
|
token += c
|
|
239
|
-
n += 1
|
|
240
251
|
if len(token) > 0:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
252
|
+
if literal:
|
|
253
|
+
token += '\n'
|
|
254
|
+
else:
|
|
255
|
+
script.tokens.append(Token(lino, token))
|
|
256
|
+
token = ''
|
|
244
257
|
return
|
|
258
|
+
|
|
259
|
+
def finish(self):
|
|
260
|
+
self.quit = True
|
|
245
261
|
|
|
246
|
-
#
|
|
247
|
-
def
|
|
248
|
-
# print(f'Run from {pc}')
|
|
249
|
-
length = len(self.queue)
|
|
250
|
-
self.queue.append(pc)
|
|
251
|
-
if length > 0:
|
|
252
|
-
return
|
|
253
|
-
|
|
262
|
+
# Flush the queue
|
|
263
|
+
def flush(self):
|
|
254
264
|
while len(self.queue):
|
|
255
265
|
self.pc = self.queue.popleft()
|
|
256
266
|
while True:
|
|
267
|
+
if self.quit:
|
|
268
|
+
return
|
|
257
269
|
command = self.code[self.pc]
|
|
258
270
|
domainName = command['domain']
|
|
259
271
|
if domainName == None:
|
|
@@ -272,11 +284,20 @@ class Program:
|
|
|
272
284
|
self.pc = handler(command)
|
|
273
285
|
try:
|
|
274
286
|
if self.pc == 0 or self.pc >= len(self.code):
|
|
275
|
-
|
|
287
|
+
break
|
|
276
288
|
except:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
289
|
+
break
|
|
290
|
+
|
|
291
|
+
def setExternalControl(self):
|
|
292
|
+
self.externalControl = True
|
|
293
|
+
|
|
294
|
+
# Run the script
|
|
295
|
+
def run(self, pc):
|
|
296
|
+
length = len(self.queue)
|
|
297
|
+
self.queue.append(pc)
|
|
298
|
+
if not self.externalControl:
|
|
299
|
+
if length == 0:
|
|
300
|
+
return self.flush()
|
|
280
301
|
|
|
281
302
|
def nonNumericValueError(self):
|
|
282
303
|
FatalError(self.compiler, 'Non-numeric value')
|
|
@@ -322,10 +343,3 @@ class Program:
|
|
|
322
343
|
if v1 < v2:
|
|
323
344
|
return -1
|
|
324
345
|
return 0
|
|
325
|
-
|
|
326
|
-
# This is the program launcher
|
|
327
|
-
def Main():
|
|
328
|
-
if (len(sys.argv) > 1):
|
|
329
|
-
Program(sys.argv[1:]).start()
|
|
330
|
-
else:
|
|
331
|
-
print('Syntax: easycoder <scriptname> [plugins]')
|