easycoder 251105.1__py2.py3-none-any.whl → 260111.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.
- easycoder/__init__.py +6 -3
- easycoder/debugger/__init__.py +5 -0
- easycoder/debugger/ec_dbg_value_display copy.py +195 -0
- easycoder/debugger/ec_dbg_value_display.py +24 -0
- easycoder/debugger/ec_dbg_watch_list copy.py +219 -0
- easycoder/debugger/ec_dbg_watchlist.py +293 -0
- easycoder/debugger/ec_debug.py +1025 -0
- easycoder/ec_classes.py +487 -11
- easycoder/ec_compiler.py +81 -44
- easycoder/ec_condition.py +1 -1
- easycoder/ec_core.py +1042 -1081
- easycoder/ec_gclasses.py +236 -0
- easycoder/ec_graphics.py +1683 -0
- easycoder/ec_handler.py +18 -14
- easycoder/ec_mqtt.py +248 -0
- easycoder/ec_program.py +297 -168
- easycoder/ec_psutil.py +48 -0
- easycoder/ec_value.py +65 -47
- easycoder/pre/README.md +3 -0
- easycoder/pre/__init__.py +17 -0
- easycoder/pre/debugger/__init__.py +5 -0
- easycoder/pre/debugger/ec_dbg_value_display copy.py +195 -0
- easycoder/pre/debugger/ec_dbg_value_display.py +24 -0
- easycoder/pre/debugger/ec_dbg_watch_list copy.py +219 -0
- easycoder/pre/debugger/ec_dbg_watchlist.py +293 -0
- easycoder/{ec_debug.py → pre/debugger/ec_debug.py} +418 -185
- easycoder/pre/ec_border.py +67 -0
- easycoder/pre/ec_classes.py +470 -0
- easycoder/pre/ec_compiler.py +291 -0
- easycoder/pre/ec_condition.py +27 -0
- easycoder/pre/ec_core.py +2772 -0
- easycoder/pre/ec_gclasses.py +230 -0
- easycoder/{ec_pyside.py → pre/ec_graphics.py} +583 -433
- easycoder/pre/ec_handler.py +79 -0
- easycoder/pre/ec_keyboard.py +439 -0
- easycoder/pre/ec_program.py +557 -0
- easycoder/pre/ec_psutil.py +48 -0
- easycoder/pre/ec_timestamp.py +11 -0
- easycoder/pre/ec_value.py +124 -0
- easycoder/pre/icons/close.png +0 -0
- easycoder/pre/icons/exit.png +0 -0
- easycoder/pre/icons/run.png +0 -0
- easycoder/pre/icons/step.png +0 -0
- easycoder/pre/icons/stop.png +0 -0
- easycoder/pre/icons/tick.png +0 -0
- {easycoder-251105.1.dist-info → easycoder-260111.1.dist-info}/METADATA +11 -1
- easycoder-260111.1.dist-info/RECORD +59 -0
- easycoder-251105.1.dist-info/RECORD +0 -24
- {easycoder-251105.1.dist-info → easycoder-260111.1.dist-info}/WHEEL +0 -0
- {easycoder-251105.1.dist-info → easycoder-260111.1.dist-info}/entry_points.txt +0 -0
- {easycoder-251105.1.dist-info → easycoder-260111.1.dist-info}/licenses/LICENSE +0 -0
easycoder/ec_compiler.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import sys
|
|
1
2
|
from .ec_classes import FatalError
|
|
2
3
|
from .ec_value import Value
|
|
3
4
|
from .ec_condition import Condition
|
|
@@ -55,10 +56,12 @@ class Compiler:
|
|
|
55
56
|
|
|
56
57
|
# Get a value
|
|
57
58
|
def getValue(self):
|
|
59
|
+
self.program.ensureNotRunning()
|
|
58
60
|
return self.value.compileValue()
|
|
59
61
|
|
|
60
62
|
# Get the next value
|
|
61
63
|
def nextValue(self):
|
|
64
|
+
self.program.ensureNotRunning()
|
|
62
65
|
self.index += 1
|
|
63
66
|
return self.value.compileValue()
|
|
64
67
|
|
|
@@ -84,7 +87,8 @@ class Compiler:
|
|
|
84
87
|
return self.program.code[pc]
|
|
85
88
|
|
|
86
89
|
# Add a command to the code list
|
|
87
|
-
def addCommand(self, command):
|
|
90
|
+
def addCommand(self, command, debug=True):
|
|
91
|
+
command['debug'] = debug
|
|
88
92
|
command['bp'] = False
|
|
89
93
|
self.code.append(command)
|
|
90
94
|
|
|
@@ -110,7 +114,19 @@ class Compiler:
|
|
|
110
114
|
if next == item:
|
|
111
115
|
self.nextToken()
|
|
112
116
|
return
|
|
113
|
-
elif next == token:
|
|
117
|
+
elif next == token:
|
|
118
|
+
self.nextToken()
|
|
119
|
+
|
|
120
|
+
# Skip common articles (optional syntactic noise for readability/disambiguation)
|
|
121
|
+
# Consumes leading articles ('the', 'a', 'an') at the next position
|
|
122
|
+
def skipArticles(self):
|
|
123
|
+
# Consume leading articles at next position(s) — like skip() but for multiple
|
|
124
|
+
while True:
|
|
125
|
+
next_tok = self.peek()
|
|
126
|
+
if next_tok in ['the', 'a', 'an']:
|
|
127
|
+
self.nextToken()
|
|
128
|
+
else:
|
|
129
|
+
break
|
|
114
130
|
|
|
115
131
|
# Rewind to a given position in the code list
|
|
116
132
|
def rewindTo(self, index):
|
|
@@ -132,58 +148,83 @@ class Compiler:
|
|
|
132
148
|
print(warning)
|
|
133
149
|
|
|
134
150
|
# Get the symbol record for the current token (assumes it is a symbol name)
|
|
135
|
-
def getSymbolRecord(self):
|
|
136
|
-
|
|
137
|
-
if
|
|
138
|
-
|
|
151
|
+
def getSymbolRecord(self, name=None):
|
|
152
|
+
self.program.ensureNotRunning()
|
|
153
|
+
if name == None: name = self.getToken()
|
|
154
|
+
if not name in self.symbols:
|
|
155
|
+
FatalError(self, f'Undefined symbol name "{name}"')
|
|
139
156
|
return None
|
|
140
|
-
symbol = self.symbols[
|
|
157
|
+
symbol = self.symbols[name]
|
|
141
158
|
if symbol == None: return None
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return
|
|
159
|
+
record = self.code[symbol]
|
|
160
|
+
record['used'] = True
|
|
161
|
+
return record
|
|
145
162
|
|
|
146
163
|
# Add a value type
|
|
147
164
|
def addValueType(self):
|
|
148
|
-
self.
|
|
165
|
+
name = self.peek()
|
|
166
|
+
record = None
|
|
167
|
+
try:
|
|
168
|
+
record = self.symbols[name]
|
|
169
|
+
except:
|
|
170
|
+
pass
|
|
171
|
+
if record != None:
|
|
172
|
+
raise FatalError(self, f'Duplicate symbol name "{name}"')
|
|
173
|
+
self.valueTypes[name] = True
|
|
149
174
|
|
|
150
175
|
# Test if a given value is in the value types list
|
|
151
176
|
def hasValue(self, type):
|
|
152
177
|
return type in self.valueTypes
|
|
153
|
-
|
|
154
|
-
#
|
|
155
|
-
def
|
|
156
|
-
|
|
178
|
+
|
|
179
|
+
# Instantiate an object of the given class name
|
|
180
|
+
def instantiate(self, classname):
|
|
181
|
+
# Search through all loaded modules for the class
|
|
182
|
+
items = sys.modules.items()
|
|
183
|
+
for module_name, module in items:
|
|
184
|
+
if module is None:
|
|
185
|
+
continue
|
|
186
|
+
try:
|
|
187
|
+
if hasattr(module, classname):
|
|
188
|
+
cls = getattr(module, classname)
|
|
189
|
+
# Verify it's actually a class
|
|
190
|
+
if isinstance(cls, type):
|
|
191
|
+
# Attempt to instantiate
|
|
192
|
+
try:
|
|
193
|
+
return cls()
|
|
194
|
+
except TypeError as ex:
|
|
195
|
+
raise FatalError(self, f"Object instantiation error: {ex}")
|
|
196
|
+
except Exception:
|
|
197
|
+
continue
|
|
198
|
+
return None
|
|
157
199
|
|
|
158
200
|
# Compile a variable
|
|
159
|
-
def compileVariable(self, command,
|
|
160
|
-
return self.compileSymbol(command, self.nextToken(),
|
|
201
|
+
def compileVariable(self, command, classname):
|
|
202
|
+
return self.compileSymbol(command, self.nextToken(), classname)
|
|
161
203
|
|
|
162
204
|
# Compile a symbol
|
|
163
|
-
def compileSymbol(self, command, name,
|
|
164
|
-
try:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if v:
|
|
169
|
-
FatalError(self, f'Duplicate symbol name "{name}"')
|
|
170
|
-
return False
|
|
171
|
-
self.symbols[name] = self.getCodeSize()
|
|
172
|
-
command['program'] = self.program
|
|
173
|
-
command['type'] = 'symbol'
|
|
205
|
+
def compileSymbol(self, command, name, classname):
|
|
206
|
+
# try:
|
|
207
|
+
# self.symbols[name]
|
|
208
|
+
# raise FatalError(self, f'Duplicate symbol name "{name}"')
|
|
209
|
+
# except: pass
|
|
174
210
|
command['name'] = name
|
|
175
|
-
command['
|
|
176
|
-
command['
|
|
177
|
-
command['value'] = [None]
|
|
211
|
+
command['classname'] = classname
|
|
212
|
+
command['program'] = self.program
|
|
178
213
|
command['used'] = False
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
214
|
+
self.symbols[name] = self.getCodeSize()
|
|
215
|
+
if classname != ':':
|
|
216
|
+
object = self.instantiate(classname)
|
|
217
|
+
command['object'] = object
|
|
218
|
+
if object != None:
|
|
219
|
+
command['type'] = 'symbol'
|
|
220
|
+
object.setName(name) # type: ignore
|
|
221
|
+
self.addCommand(command, False)
|
|
185
222
|
return True
|
|
186
223
|
|
|
224
|
+
# Compile a program label (a symbol ending with ':')
|
|
225
|
+
def compileLabel(self, command):
|
|
226
|
+
return self.compileSymbol(command, self.getToken(), ':')
|
|
227
|
+
|
|
187
228
|
# Compile the current token
|
|
188
229
|
def compileToken(self):
|
|
189
230
|
self.warnings = []
|
|
@@ -192,8 +233,8 @@ class Compiler:
|
|
|
192
233
|
if not token:
|
|
193
234
|
return False
|
|
194
235
|
if len(self.code) == 0:
|
|
195
|
-
if self.program.parent == None and self.program.
|
|
196
|
-
cmd = {'domain': 'graphics', 'keyword': 'init'
|
|
236
|
+
if self.program.parent == None and self.program.graphics:
|
|
237
|
+
cmd = {'domain': 'graphics', 'keyword': 'init'}
|
|
197
238
|
self.code.append(cmd)
|
|
198
239
|
mark = self.getIndex()
|
|
199
240
|
for domain in self.program.getDomains():
|
|
@@ -203,8 +244,6 @@ class Compiler:
|
|
|
203
244
|
command['domain'] = domain.getName()
|
|
204
245
|
command['lino'] = self.tokens[self.index].lino
|
|
205
246
|
command['keyword'] = token
|
|
206
|
-
command['type'] = None
|
|
207
|
-
command['debug'] = True
|
|
208
247
|
result = handler(command)
|
|
209
248
|
if result:
|
|
210
249
|
return result
|
|
@@ -233,9 +272,7 @@ class Compiler:
|
|
|
233
272
|
self.index = index
|
|
234
273
|
while True:
|
|
235
274
|
token = self.tokens[self.index]
|
|
236
|
-
|
|
237
|
-
if self.debugCompile: print(self.script.lines[token.lino])
|
|
238
|
-
# if keyword != 'else':
|
|
275
|
+
if self.debugCompile: print(f'{token.lino + 1}: {self.script.lines[token.lino]}')
|
|
239
276
|
if self.compileOne() == True:
|
|
240
277
|
if self.index == len(self.tokens) - 1:
|
|
241
278
|
return True
|
easycoder/ec_condition.py
CHANGED
|
@@ -16,7 +16,7 @@ class Condition:
|
|
|
16
16
|
for domain in self.compiler.program.getDomains():
|
|
17
17
|
condition = domain.compileCondition()
|
|
18
18
|
if condition != None:
|
|
19
|
-
condition.domain= domain.getName()
|
|
19
|
+
condition.domain = domain.getName()
|
|
20
20
|
return condition
|
|
21
21
|
self.rewindTo(mark)
|
|
22
22
|
return None
|