easycoder 250104.1__tar.gz → 250105.1__tar.gz
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-250104.1 → easycoder-250105.1}/PKG-INFO +1 -1
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/run.md +2 -2
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/__init__.py +1 -1
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_core.py +100 -36
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_graphics.py +1 -1
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_program.py +29 -14
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_renderer.py +2 -0
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_value.py +1 -1
- {easycoder-250104.1 → easycoder-250105.1}/scripts/benchmark.ecs +1 -0
- {easycoder-250104.1 → easycoder-250105.1}/scripts/fizzbuzz.ecs +1 -0
- {easycoder-250104.1 → easycoder-250105.1}/scripts/hello.ecs +1 -0
- {easycoder-250104.1 → easycoder-250105.1}/scripts/points.ecs +2 -1
- {easycoder-250104.1 → easycoder-250105.1}/scripts/tests.ecs +2 -0
- {easycoder-250104.1 → easycoder-250105.1}/LICENSE +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/README.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/README.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/README.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/boolean.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/empty.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/ends.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/even.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/exists.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/greater.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/hasProperty.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/includes.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/is.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/less.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/list.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/none.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/not.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/numeric.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/object.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/odd.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/starts.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/conditions/string.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/add.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/append.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/assert.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/begin.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/clear.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/close.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/create.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/debug.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/decrement.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/delete.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/divide.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/exit.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/file.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/fork.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/get.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/go.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/gosub.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/if.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/import.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/increment.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/index.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/init.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/input.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/load.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/lock.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/module.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/multiply.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/negate.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/open.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/pop.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/post.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/print.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/push.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/put.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/read.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/release.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/replace.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/return.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/save.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/script.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/set.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/split.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/stack.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/stop.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/system.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/take.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/toggle.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/truncate.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/unlock.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/variable.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/wait.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/while.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/keywords/write.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/arg.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/args.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/cos.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/datime.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/decode.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/element.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/elements.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/empty.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/encode.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/error.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/files.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/float.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/from.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/hash.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/index.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/integer.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/json.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/keys.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/left.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/length.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/lowercase.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/memory.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/modification.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/modulo.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/newline.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/now.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/position.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/property.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/random.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/right.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/sin.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/stringify.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/tab.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/tan.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/timestamp.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/today.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/trim.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/type.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/uppercase.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/value.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/core/values/weekday.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/doc/graphics/README.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/README.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec.py +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_classes.py +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_compiler.py +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_condition.py +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_handler.py +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_screenspec.py +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/easycoder/ec_timestamp.py +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/images/Semoigo Dawn.jpg +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/json/graphics-demo.json +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/plugins/ec_p100.py +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/plugins/example.py +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/pyproject.toml +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/scripts/README.md +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/scripts/graphics-demo.ecg +0 -0
- {easycoder-250104.1 → easycoder-250105.1}/scripts/wave.ecg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: easycoder
|
|
3
|
-
Version:
|
|
3
|
+
Version: 250105.1
|
|
4
4
|
Summary: Rapid scripting in English
|
|
5
5
|
Keywords: compiler,scripting,prototyping,programming,coding,python,low code,hypertalk,computer language,learn to code
|
|
6
6
|
Author-email: Graham Trott <gtanyware@gmail.com>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# run
|
|
2
2
|
|
|
3
3
|
## Syntax:
|
|
4
|
-
`run {module} as
|
|
4
|
+
`run {name} {module} as [with {export} [and {export}...]]`
|
|
5
5
|
|
|
6
6
|
## Example:
|
|
7
7
|
``run Hello as `hello.ecs` with Name and Surname` ``
|
|
8
8
|
|
|
9
9
|
## Description:
|
|
10
|
-
Run a second script, optionally passing it variables it can use. Changes to these variables will be seen by the parent script (but see [lock](lock.md)). See also [release](release.md).
|
|
10
|
+
Run a second script, optionally passing it variables it can use. Changes to these variables will be seen by the parent script (but see [lock](lock.md)). See also [module](module.md), [release](release.md), [send](send.md)and [on](on.md).
|
|
11
11
|
|
|
12
12
|
Next: [multiply](multiply.md)
|
|
13
13
|
Prev: [lock](lock.md)
|
|
@@ -552,27 +552,37 @@ class Core(Handler):
|
|
|
552
552
|
self.program.pc += 1
|
|
553
553
|
return self.program.pc
|
|
554
554
|
|
|
555
|
-
# Import one or more variables
|
|
556
555
|
def k_import(self, command):
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
keyword = self.nextToken()
|
|
560
|
-
name = self.nextToken()
|
|
561
|
-
item = [keyword, name]
|
|
562
|
-
imports.append(item)
|
|
563
|
-
self.symbols[name] = self.getPC()
|
|
564
|
-
variable = {}
|
|
565
|
-
variable['domain'] = None
|
|
566
|
-
variable['name'] = name
|
|
567
|
-
variable['keyword'] = keyword
|
|
568
|
-
variable['import'] = None
|
|
569
|
-
self.addCommand(variable)
|
|
570
|
-
if self.peek() != 'and':
|
|
571
|
-
break
|
|
556
|
+
if self.peek() == 'plugin':
|
|
557
|
+
# Import a plugin
|
|
572
558
|
self.nextToken()
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
559
|
+
clazz = self.nextToken()
|
|
560
|
+
if self.nextIs('from'):
|
|
561
|
+
source = self.nextToken()
|
|
562
|
+
self.program.importPlugin(f'{source}:{clazz}')
|
|
563
|
+
return True
|
|
564
|
+
return False
|
|
565
|
+
else:
|
|
566
|
+
# Import one or more variables
|
|
567
|
+
imports = []
|
|
568
|
+
while True:
|
|
569
|
+
keyword = self.nextToken()
|
|
570
|
+
name = self.nextToken()
|
|
571
|
+
item = [keyword, name]
|
|
572
|
+
imports.append(item)
|
|
573
|
+
self.symbols[name] = self.getPC()
|
|
574
|
+
variable = {}
|
|
575
|
+
variable['domain'] = None
|
|
576
|
+
variable['name'] = name
|
|
577
|
+
variable['keyword'] = keyword
|
|
578
|
+
variable['import'] = None
|
|
579
|
+
self.addCommand(variable)
|
|
580
|
+
if self.peek() != 'and':
|
|
581
|
+
break
|
|
582
|
+
self.nextToken()
|
|
583
|
+
command['imports'] = json.dumps(imports)
|
|
584
|
+
self.add(command)
|
|
585
|
+
return True
|
|
576
586
|
|
|
577
587
|
def r_import(self, command):
|
|
578
588
|
exports = self.program.exports
|
|
@@ -694,11 +704,8 @@ class Core(Handler):
|
|
|
694
704
|
return False
|
|
695
705
|
|
|
696
706
|
def r_load(self, command):
|
|
697
|
-
print(command)
|
|
698
707
|
target = self.getVariable(command['target'])
|
|
699
|
-
print(target)
|
|
700
708
|
file = self.getRuntimeValue(command['file'])
|
|
701
|
-
print(file)
|
|
702
709
|
f = open(file, 'r')
|
|
703
710
|
content = f.read()
|
|
704
711
|
f.close()
|
|
@@ -810,6 +817,36 @@ class Core(Handler):
|
|
|
810
817
|
def r_object(self, command):
|
|
811
818
|
return self.nextPC()
|
|
812
819
|
|
|
820
|
+
# on message {action}
|
|
821
|
+
def k_on(self, command):
|
|
822
|
+
if self.nextIs('message'):
|
|
823
|
+
self.nextToken()
|
|
824
|
+
command['goto'] = 0
|
|
825
|
+
self.add(command)
|
|
826
|
+
cmd = {}
|
|
827
|
+
cmd['domain'] = 'core'
|
|
828
|
+
cmd['lino'] = command['lino']
|
|
829
|
+
cmd['keyword'] = 'gotoPC'
|
|
830
|
+
cmd['goto'] = 0
|
|
831
|
+
cmd['debug'] = False
|
|
832
|
+
self.addCommand(cmd)
|
|
833
|
+
# Add the action and a 'stop'
|
|
834
|
+
self.compileOne()
|
|
835
|
+
cmd = {}
|
|
836
|
+
cmd['domain'] = 'core'
|
|
837
|
+
cmd['lino'] = command['lino']
|
|
838
|
+
cmd['keyword'] = 'stop'
|
|
839
|
+
cmd['debug'] = False
|
|
840
|
+
self.addCommand(cmd)
|
|
841
|
+
# Fixup the link
|
|
842
|
+
command['goto'] = self.getPC()
|
|
843
|
+
return True
|
|
844
|
+
return False
|
|
845
|
+
|
|
846
|
+
def r_on(self, command):
|
|
847
|
+
self.program.onMessage(self.nextPC()+1)
|
|
848
|
+
return command['goto']
|
|
849
|
+
|
|
813
850
|
# Open a file
|
|
814
851
|
# open {file} for reading/writing/appending
|
|
815
852
|
def k_open(self, command):
|
|
@@ -1002,13 +1039,13 @@ class Core(Handler):
|
|
|
1002
1039
|
if self.nextIsSymbol():
|
|
1003
1040
|
symbolRecord = self.getSymbolRecord()
|
|
1004
1041
|
command['target'] = symbolRecord['name']
|
|
1005
|
-
if symbolRecord['valueHolder']:
|
|
1042
|
+
if 'valueholder' in symbolRecord and symbolRecord['valueHolder'] == False:
|
|
1043
|
+
FatalError(self.program.compiler, f'Symbol {symbolRecord["name"]} is not a value holder')
|
|
1044
|
+
else:
|
|
1006
1045
|
self.add(command)
|
|
1007
1046
|
return True
|
|
1008
|
-
else:
|
|
1009
|
-
FatalError(self.program.compiler, f'Symbol {symbolRecord["name"]} is not a value holder')
|
|
1010
1047
|
else:
|
|
1011
|
-
FatalError(self.program.compiler, f'
|
|
1048
|
+
FatalError(self.program.compiler, f'Symbol {self.getToken()} is not a variable')
|
|
1012
1049
|
return False
|
|
1013
1050
|
|
|
1014
1051
|
def r_put(self, command):
|
|
@@ -1111,12 +1148,16 @@ class Core(Handler):
|
|
|
1111
1148
|
|
|
1112
1149
|
# Compile and run a script
|
|
1113
1150
|
def k_run(self, command):
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1151
|
+
try:
|
|
1152
|
+
command['path'] = self.nextValue()
|
|
1153
|
+
except Exception as e:
|
|
1154
|
+
self.warning(f'Core.run: Path expected')
|
|
1155
|
+
return False
|
|
1156
|
+
if self.nextIs('as'):
|
|
1157
|
+
if self.nextIsSymbol():
|
|
1158
|
+
record = self.getSymbolRecord()
|
|
1159
|
+
if record['keyword'] == 'module':
|
|
1160
|
+
command['module'] = record['name']
|
|
1120
1161
|
exports = []
|
|
1121
1162
|
if self.nextIs('with'):
|
|
1122
1163
|
while True:
|
|
@@ -1132,18 +1173,18 @@ class Core(Handler):
|
|
|
1132
1173
|
return False
|
|
1133
1174
|
|
|
1134
1175
|
def r_run(self, command):
|
|
1135
|
-
|
|
1176
|
+
module = self.getVariable(command['module'])
|
|
1136
1177
|
path = self.getRuntimeValue(command['path'])
|
|
1137
1178
|
exports = json.loads(command['exports'])
|
|
1138
1179
|
for n in range(0, len(exports)):
|
|
1139
1180
|
exports[n] = self.getVariable(exports[n])
|
|
1140
|
-
|
|
1181
|
+
module['path'] = path
|
|
1141
1182
|
parent = Object()
|
|
1142
1183
|
parent.program = self.program
|
|
1143
1184
|
parent.pc = self.nextPC()
|
|
1144
1185
|
parent.waiting = True
|
|
1145
1186
|
p = self.program.__class__
|
|
1146
|
-
p(path).start(parent, exports)
|
|
1187
|
+
p(path).start(parent, module, exports)
|
|
1147
1188
|
return 0
|
|
1148
1189
|
|
|
1149
1190
|
# Provide a name for the script
|
|
@@ -1168,6 +1209,24 @@ class Core(Handler):
|
|
|
1168
1209
|
f.close()
|
|
1169
1210
|
return self.nextPC()
|
|
1170
1211
|
|
|
1212
|
+
# Send a message to a module
|
|
1213
|
+
def k_send(self, command):
|
|
1214
|
+
command['message'] = self.nextValue()
|
|
1215
|
+
if self.nextIs('to'):
|
|
1216
|
+
if self.nextIsSymbol():
|
|
1217
|
+
record = self.getSymbolRecord()
|
|
1218
|
+
if record['keyword'] == 'module':
|
|
1219
|
+
command['module'] = record['name']
|
|
1220
|
+
self.add(command)
|
|
1221
|
+
return True
|
|
1222
|
+
return False
|
|
1223
|
+
|
|
1224
|
+
def r_send(self, command):
|
|
1225
|
+
message = self.getRuntimeValue(command['message'])
|
|
1226
|
+
module = self.getVariable(command['module'])
|
|
1227
|
+
module['child'].handleMessage(message)
|
|
1228
|
+
return self.nextPC()
|
|
1229
|
+
|
|
1171
1230
|
# Set a value
|
|
1172
1231
|
# set {variable}
|
|
1173
1232
|
# set the elements of {variable} to {value}
|
|
@@ -1791,7 +1850,6 @@ class Core(Handler):
|
|
|
1791
1850
|
return value
|
|
1792
1851
|
|
|
1793
1852
|
if token == 'message':
|
|
1794
|
-
self.nextToken()
|
|
1795
1853
|
return value
|
|
1796
1854
|
|
|
1797
1855
|
if token == 'timestamp':
|
|
@@ -2097,6 +2155,12 @@ class Core(Handler):
|
|
|
2097
2155
|
value['content'] = megabytes
|
|
2098
2156
|
return value
|
|
2099
2157
|
|
|
2158
|
+
def v_message(self, v):
|
|
2159
|
+
value = {}
|
|
2160
|
+
value['type'] = 'text'
|
|
2161
|
+
value['content'] = self.program.message
|
|
2162
|
+
return value
|
|
2163
|
+
|
|
2100
2164
|
def v_modification(self, v):
|
|
2101
2165
|
fileName = self.getRuntimeValue(v['fileName'])
|
|
2102
2166
|
ts = int(os.stat(fileName).st_mtime)
|
|
@@ -176,7 +176,7 @@ class Graphics(Handler):
|
|
|
176
176
|
self.windowSpec = Object()
|
|
177
177
|
self.windowSpec.title = command['title']['content']
|
|
178
178
|
self.windowSpec.flush = flush
|
|
179
|
-
self.windowSpec.
|
|
179
|
+
self.windowSpec.kill = self.program.kill
|
|
180
180
|
self.windowSpec.pos = (self.getRuntimeValue(command['pos'][0]), self.getRuntimeValue(command['pos'][1]))
|
|
181
181
|
self.windowSpec.size = (self.getRuntimeValue(command['size'][0]), self.getRuntimeValue(command['size'][1]))
|
|
182
182
|
self.windowSpec.fill = (self.getRuntimeValue(command['fill'][0])/255, self.getRuntimeValue(command['fill'][1])/255, self.getRuntimeValue(command['fill'][2])/255)
|
|
@@ -7,8 +7,6 @@ from .ec_core import Core
|
|
|
7
7
|
import importlib
|
|
8
8
|
from importlib.metadata import version
|
|
9
9
|
|
|
10
|
-
queue = deque()
|
|
11
|
-
|
|
12
10
|
# Flush the queue
|
|
13
11
|
def flush():
|
|
14
12
|
global queue
|
|
@@ -19,6 +17,7 @@ def flush():
|
|
|
19
17
|
class Program:
|
|
20
18
|
|
|
21
19
|
def __init__(self, argv):
|
|
20
|
+
global queue
|
|
22
21
|
print(f'EasyCoder version {version("easycoder")}')
|
|
23
22
|
if len(argv) == 0:
|
|
24
23
|
print('No script supplied')
|
|
@@ -32,6 +31,7 @@ class Program:
|
|
|
32
31
|
f = open(scriptName, 'r')
|
|
33
32
|
source = f.read()
|
|
34
33
|
f.close()
|
|
34
|
+
queue = deque()
|
|
35
35
|
self.argv = argv
|
|
36
36
|
self.domains = []
|
|
37
37
|
self.domainIndex = {}
|
|
@@ -48,11 +48,13 @@ class Program:
|
|
|
48
48
|
self.condition = self.compiler.condition
|
|
49
49
|
self.processClasses()
|
|
50
50
|
self.externalControl = False
|
|
51
|
-
self.
|
|
51
|
+
self.running = True
|
|
52
52
|
|
|
53
|
-
def start(self, parent=None, exports=[]):
|
|
53
|
+
def start(self, parent=None, module = None, exports=[]):
|
|
54
54
|
self.parent = parent
|
|
55
55
|
self.exports = exports
|
|
56
|
+
if module != None:
|
|
57
|
+
module['child'] = self
|
|
56
58
|
startCompile = time.time()
|
|
57
59
|
self.tokenise(self.script)
|
|
58
60
|
if self.compiler.compileFrom(0, []):
|
|
@@ -70,7 +72,15 @@ class Program:
|
|
|
70
72
|
self.run(0)
|
|
71
73
|
else:
|
|
72
74
|
self.compiler.showWarnings()
|
|
73
|
-
|
|
75
|
+
|
|
76
|
+
# If this is the main script and there's no graphics, run a main loop
|
|
77
|
+
if parent == None and self.externalControl == False:
|
|
78
|
+
while True:
|
|
79
|
+
if self.running == True:
|
|
80
|
+
flush()
|
|
81
|
+
time.sleep(0.1)
|
|
82
|
+
else:
|
|
83
|
+
break
|
|
74
84
|
|
|
75
85
|
# Import a plugin
|
|
76
86
|
def importPlugin(self, source):
|
|
@@ -140,7 +150,7 @@ class Program:
|
|
|
140
150
|
name = value['name']
|
|
141
151
|
symbolRecord = self.getSymbolRecord(name)
|
|
142
152
|
if symbolRecord['value'] == [None]:
|
|
143
|
-
RuntimeWarning(self.
|
|
153
|
+
RuntimeWarning(self.program, f'Variable "{name}" has no value')
|
|
144
154
|
return None
|
|
145
155
|
handler = self.domainIndex[symbolRecord['domain']].valueHandler('symbol')
|
|
146
156
|
result = handler(symbolRecord)
|
|
@@ -277,7 +287,6 @@ class Program:
|
|
|
277
287
|
# Flush the queue
|
|
278
288
|
def flush(self, pc):
|
|
279
289
|
global queue
|
|
280
|
-
self.running = True
|
|
281
290
|
self.pc = pc
|
|
282
291
|
while True:
|
|
283
292
|
command = self.code[self.pc]
|
|
@@ -299,26 +308,23 @@ class Program:
|
|
|
299
308
|
# Deal with 'exit'
|
|
300
309
|
if self.pc == -1:
|
|
301
310
|
queue = deque()
|
|
302
|
-
self.running = False
|
|
303
311
|
if self.parent != None:
|
|
304
312
|
self.releaseParent()
|
|
305
|
-
|
|
313
|
+
else:
|
|
314
|
+
self.running = False
|
|
315
|
+
break
|
|
306
316
|
elif self.pc == None or self.pc == 0 or self.pc >= len(self.code):
|
|
307
317
|
break
|
|
308
318
|
|
|
309
319
|
# Run the script
|
|
310
320
|
def run(self, pc):
|
|
311
321
|
global queue
|
|
312
|
-
length = len(queue)
|
|
313
322
|
item = Object()
|
|
314
323
|
item.program = self
|
|
315
324
|
item.pc = pc
|
|
316
325
|
queue.append(item)
|
|
317
|
-
if not self.externalControl:
|
|
318
|
-
if length == 0:
|
|
319
|
-
return flush()
|
|
320
326
|
|
|
321
|
-
def
|
|
327
|
+
def kill(self):
|
|
322
328
|
self.running = False
|
|
323
329
|
|
|
324
330
|
def setExternalControl(self):
|
|
@@ -368,6 +374,15 @@ class Program:
|
|
|
368
374
|
if v1 < v2:
|
|
369
375
|
return -1
|
|
370
376
|
return 0
|
|
377
|
+
|
|
378
|
+
# Set up a message handler
|
|
379
|
+
def onMessage(self, pc):
|
|
380
|
+
self.onMessagePC = pc
|
|
381
|
+
|
|
382
|
+
# Handle a message from our parent program
|
|
383
|
+
def handleMessage(self, message):
|
|
384
|
+
self.message = message
|
|
385
|
+
self.run(self.onMessagePC)
|
|
371
386
|
|
|
372
387
|
# This is the program launcher
|
|
373
388
|
def Main():
|
|
@@ -225,6 +225,7 @@ class Renderer(App):
|
|
|
225
225
|
|
|
226
226
|
def request_close(self):
|
|
227
227
|
print('close window')
|
|
228
|
+
self.kill()
|
|
228
229
|
Window.close()
|
|
229
230
|
|
|
230
231
|
def flushQueue(self, dt):
|
|
@@ -238,6 +239,7 @@ class Renderer(App):
|
|
|
238
239
|
self.ui = UI()
|
|
239
240
|
self.title = spec.title
|
|
240
241
|
self.flush = spec.flush
|
|
242
|
+
self.kill = spec.kill
|
|
241
243
|
Window.size = spec.size
|
|
242
244
|
Window.left = spec.pos[0]
|
|
243
245
|
Window.top = spec.pos[1]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
script Points
|
|
4
4
|
|
|
5
|
-
import Points from plugins/example.py
|
|
5
|
+
import plugin Points from plugins/example.py
|
|
6
6
|
|
|
7
7
|
point Point1
|
|
8
8
|
point Point2
|
|
@@ -14,3 +14,4 @@
|
|
|
14
14
|
put the distance between Point1 and Point2 into Distance
|
|
15
15
|
assert Distance is 250 with `Distance is ` cat Distance cat `: should be 250`
|
|
16
16
|
print `The distance is ` cat Distance cat ` units`
|
|
17
|
+
exit
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|