easycoder 251104.2__py2.py3-none-any.whl → 260110.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.

Files changed (60) hide show
  1. easycoder/__init__.py +5 -3
  2. easycoder/debugger/__init__.py +5 -0
  3. easycoder/debugger/ec_dbg_value_display copy.py +195 -0
  4. easycoder/debugger/ec_dbg_value_display.py +24 -0
  5. easycoder/debugger/ec_dbg_watch_list copy.py +219 -0
  6. easycoder/debugger/ec_dbg_watchlist.py +293 -0
  7. easycoder/debugger/ec_debug.py +1025 -0
  8. easycoder/ec_border.py +15 -11
  9. easycoder/ec_classes.py +487 -11
  10. easycoder/ec_compiler.py +81 -44
  11. easycoder/ec_condition.py +1 -1
  12. easycoder/ec_core.py +1044 -1090
  13. easycoder/ec_gclasses.py +236 -0
  14. easycoder/ec_graphics.py +1683 -0
  15. easycoder/ec_handler.py +18 -13
  16. easycoder/ec_keyboard.py +50 -50
  17. easycoder/ec_program.py +299 -156
  18. easycoder/ec_psutil.py +48 -0
  19. easycoder/ec_timestamp.py +2 -1
  20. easycoder/ec_value.py +65 -47
  21. easycoder/icons/exit.png +0 -0
  22. easycoder/icons/run.png +0 -0
  23. easycoder/icons/step.png +0 -0
  24. easycoder/icons/stop.png +0 -0
  25. easycoder/pre/README.md +3 -0
  26. easycoder/pre/__init__.py +17 -0
  27. easycoder/pre/debugger/__init__.py +5 -0
  28. easycoder/pre/debugger/ec_dbg_value_display copy.py +195 -0
  29. easycoder/pre/debugger/ec_dbg_value_display.py +24 -0
  30. easycoder/pre/debugger/ec_dbg_watch_list copy.py +219 -0
  31. easycoder/pre/debugger/ec_dbg_watchlist.py +293 -0
  32. easycoder/pre/debugger/ec_debug.py +1014 -0
  33. easycoder/pre/ec_border.py +67 -0
  34. easycoder/pre/ec_classes.py +470 -0
  35. easycoder/pre/ec_compiler.py +291 -0
  36. easycoder/pre/ec_condition.py +27 -0
  37. easycoder/pre/ec_core.py +2772 -0
  38. easycoder/pre/ec_gclasses.py +230 -0
  39. easycoder/{ec_pyside.py → pre/ec_graphics.py} +631 -496
  40. easycoder/pre/ec_handler.py +79 -0
  41. easycoder/pre/ec_keyboard.py +439 -0
  42. easycoder/pre/ec_program.py +557 -0
  43. easycoder/pre/ec_psutil.py +48 -0
  44. easycoder/pre/ec_timestamp.py +11 -0
  45. easycoder/pre/ec_value.py +124 -0
  46. easycoder/pre/icons/close.png +0 -0
  47. easycoder/pre/icons/exit.png +0 -0
  48. easycoder/pre/icons/run.png +0 -0
  49. easycoder/pre/icons/step.png +0 -0
  50. easycoder/pre/icons/stop.png +0 -0
  51. easycoder/pre/icons/tick.png +0 -0
  52. {easycoder-251104.2.dist-info → easycoder-260110.1.dist-info}/METADATA +11 -1
  53. easycoder-260110.1.dist-info/RECORD +58 -0
  54. easycoder/ec_debug.py +0 -464
  55. easycoder-251104.2.dist-info/RECORD +0 -20
  56. /easycoder/{close.png → icons/close.png} +0 -0
  57. /easycoder/{tick.png → icons/tick.png} +0 -0
  58. {easycoder-251104.2.dist-info → easycoder-260110.1.dist-info}/WHEEL +0 -0
  59. {easycoder-251104.2.dist-info → easycoder-260110.1.dist-info}/entry_points.txt +0 -0
  60. {easycoder-251104.2.dist-info → easycoder-260110.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: self.nextToken()
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
- token = self.getToken()
137
- if not token in self.symbols:
138
- FatalError(self, f'Undefined symbol name "{token}"')
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[token]
157
+ symbol = self.symbols[name]
141
158
  if symbol == None: return None
142
- symbolRecord = self.code[symbol]
143
- symbolRecord['used'] = True
144
- return symbolRecord
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.valueTypes[self.getToken()] = True
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
- # Compile a program label (a symbol ending with ':')
155
- def compileLabel(self, command):
156
- return self.compileSymbol(command, self.getToken())
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, extra=None):
160
- return self.compileSymbol(command, self.nextToken(), extra)
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, extra=None):
164
- try:
165
- v = self.symbols[name]
166
- except:
167
- v = None
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['elements'] = 1
176
- command['index'] = 0
177
- command['value'] = [None]
211
+ command['classname'] = classname
212
+ command['program'] = self.program
178
213
  command['used'] = False
179
- command['debug'] = False
180
- command['import'] = None
181
- command['locked'] = False
182
- command['extra'] = extra
183
- if 'keyword' in command: command['hasValue'] = self.hasValue(command['keyword'])
184
- self.addCommand(command)
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.usingGraphics:
196
- cmd = {'domain': 'graphics', 'keyword': 'init', 'debug': False}
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
- # keyword = token.token
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