easycoder 241211.2__tar.gz → 241211.3__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.

Files changed (67) hide show
  1. {easycoder-241211.2 → easycoder-241211.3}/PKG-INFO +9 -8
  2. {easycoder-241211.2 → easycoder-241211.3}/README.md +8 -7
  3. easycoder-241211.2/doc/core.md → easycoder-241211.3/doc/README.md +8 -0
  4. {easycoder-241211.2 → easycoder-241211.3}/doc/core/add.md +1 -1
  5. {easycoder-241211.2 → easycoder-241211.3}/doc/core/append.md +1 -1
  6. {easycoder-241211.2 → easycoder-241211.3}/doc/core/assert.md +1 -1
  7. {easycoder-241211.2 → easycoder-241211.3}/doc/core/begin.md +1 -1
  8. {easycoder-241211.2 → easycoder-241211.3}/doc/core/clear.md +1 -1
  9. {easycoder-241211.2 → easycoder-241211.3}/doc/core/close.md +1 -1
  10. {easycoder-241211.2 → easycoder-241211.3}/doc/core/create.md +1 -1
  11. {easycoder-241211.2 → easycoder-241211.3}/doc/core/debug.md +1 -1
  12. {easycoder-241211.2 → easycoder-241211.3}/doc/core/decrement.md +1 -1
  13. {easycoder-241211.2 → easycoder-241211.3}/doc/core/delete.md +1 -1
  14. {easycoder-241211.2 → easycoder-241211.3}/doc/core/divide.md +1 -1
  15. {easycoder-241211.2 → easycoder-241211.3}/doc/core/exit.md +1 -1
  16. {easycoder-241211.2 → easycoder-241211.3}/doc/core/file.md +1 -1
  17. {easycoder-241211.2 → easycoder-241211.3}/doc/core/fork.md +1 -1
  18. {easycoder-241211.2 → easycoder-241211.3}/doc/core/get.md +1 -1
  19. {easycoder-241211.2 → easycoder-241211.3}/doc/core/go.md +1 -1
  20. {easycoder-241211.2 → easycoder-241211.3}/doc/core/gosub.md +1 -1
  21. {easycoder-241211.2 → easycoder-241211.3}/doc/core/if.md +1 -1
  22. {easycoder-241211.2 → easycoder-241211.3}/doc/core/increment.md +1 -1
  23. {easycoder-241211.2 → easycoder-241211.3}/doc/core/index.md +1 -1
  24. {easycoder-241211.2 → easycoder-241211.3}/doc/core/init.md +1 -1
  25. {easycoder-241211.2 → easycoder-241211.3}/doc/core/input.md +1 -1
  26. {easycoder-241211.2 → easycoder-241211.3}/doc/core/multiply.md +1 -1
  27. {easycoder-241211.2 → easycoder-241211.3}/doc/core/open.md +1 -1
  28. {easycoder-241211.2 → easycoder-241211.3}/doc/core/pop.md +1 -1
  29. {easycoder-241211.2 → easycoder-241211.3}/doc/core/post.md +1 -1
  30. {easycoder-241211.2 → easycoder-241211.3}/doc/core/print.md +1 -1
  31. {easycoder-241211.2 → easycoder-241211.3}/doc/core/push.md +1 -1
  32. {easycoder-241211.2 → easycoder-241211.3}/doc/core/put.md +1 -1
  33. {easycoder-241211.2 → easycoder-241211.3}/doc/core/read.md +1 -1
  34. {easycoder-241211.2 → easycoder-241211.3}/doc/core/replace.md +1 -1
  35. {easycoder-241211.2 → easycoder-241211.3}/doc/core/return.md +1 -1
  36. {easycoder-241211.2 → easycoder-241211.3}/doc/core/script.md +1 -1
  37. {easycoder-241211.2 → easycoder-241211.3}/doc/core/set.md +1 -1
  38. {easycoder-241211.2 → easycoder-241211.3}/doc/core/split.md +1 -1
  39. {easycoder-241211.2 → easycoder-241211.3}/doc/core/stack.md +1 -1
  40. {easycoder-241211.2 → easycoder-241211.3}/doc/core/stop.md +1 -1
  41. {easycoder-241211.2 → easycoder-241211.3}/doc/core/system.md +1 -1
  42. {easycoder-241211.2 → easycoder-241211.3}/doc/core/take.md +1 -1
  43. {easycoder-241211.2 → easycoder-241211.3}/doc/core/toggle.md +1 -1
  44. {easycoder-241211.2 → easycoder-241211.3}/doc/core/truncate.md +1 -1
  45. {easycoder-241211.2 → easycoder-241211.3}/doc/core/variable.md +1 -1
  46. {easycoder-241211.2 → easycoder-241211.3}/doc/core/wait.md +1 -1
  47. {easycoder-241211.2 → easycoder-241211.3}/doc/core/while.md +1 -1
  48. {easycoder-241211.2 → easycoder-241211.3}/doc/core/write.md +1 -1
  49. {easycoder-241211.2 → easycoder-241211.3}/easycoder/__init__.py +1 -1
  50. {easycoder-241211.2 → easycoder-241211.3}/easycoder/ec_classes.py +5 -2
  51. {easycoder-241211.2 → easycoder-241211.3}/easycoder/ec_core.py +1 -1
  52. easycoder-241211.3/plugins/example.py +90 -0
  53. easycoder-241211.3/scripts/points.ecs +16 -0
  54. {easycoder-241211.2 → easycoder-241211.3}/LICENSE +0 -0
  55. {easycoder-241211.2 → easycoder-241211.3}/easycoder/ec_compiler.py +0 -0
  56. {easycoder-241211.2 → easycoder-241211.3}/easycoder/ec_condition.py +0 -0
  57. {easycoder-241211.2 → easycoder-241211.3}/easycoder/ec_handler.py +0 -0
  58. {easycoder-241211.2 → easycoder-241211.3}/easycoder/ec_program.py +0 -0
  59. {easycoder-241211.2 → easycoder-241211.3}/easycoder/ec_timestamp.py +0 -0
  60. {easycoder-241211.2 → easycoder-241211.3}/easycoder/ec_value.py +0 -0
  61. {easycoder-241211.2 → easycoder-241211.3}/plugins/ec_p100.py +0 -0
  62. {easycoder-241211.2 → easycoder-241211.3}/pyproject.toml +0 -0
  63. {easycoder-241211.2 → easycoder-241211.3}/scripts/benchmark.ecs +0 -0
  64. {easycoder-241211.2 → easycoder-241211.3}/scripts/fizzbuzz.ecs +0 -0
  65. {easycoder-241211.2 → easycoder-241211.3}/scripts/hello.ecs +0 -0
  66. {easycoder-241211.2 → easycoder-241211.3}/scripts/tests.ecs +0 -0
  67. {easycoder-241211.2 → easycoder-241211.3}/test.ecs +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: easycoder
3
- Version: 241211.2
3
+ Version: 241211.3
4
4
  Summary: EasyCoder for Python
5
5
  Author-email: Graham Trott <gtanyware@gmail.com>
6
6
  Description-Content-Type: text/markdown
@@ -58,14 +58,15 @@ Here in the repository is a folder called `scripts` containing some sample scrip
58
58
  `tests.ecs` is a test program containing many of the EasyCoder features
59
59
  `fizzbuzz.ecs` is a simple programming challenge often given at job interviews
60
60
 
61
- ## The EasyCoder programming language
62
- There are three primary components to the language:
63
-
64
- - Keywords
65
- - Values
66
- - Conditions
61
+ ## EasyCoder programming reference
67
62
 
68
63
  The language comprises a general-purpose core package, which can be enhanced by plugins to provide special features on demand.
69
64
 
70
- [The core package](doc/core.md)
65
+ [The core package](doc/README.md)
66
+
67
+ ## Extending the language
68
+
69
+ **_EasyCoder_** can be extended to add new functionality with the use of 'plugins'. These contain compiler and runtime modules for the added language features. **_EasyCoder_** can use the added keywords, values and conditions freely; the effect is completely seamless. There is an outline example in the `plugins` directory called `example.py`, which comprises a module called `Points` with new language syntax to deal with two-valued items such as coordinates. In the `scripts` directory there is `points.ecs`, which exercises the new functionality.
70
+
71
+ A plugin can act as a wrapper around any Python functionality that has a sensible API, thereby hiding its complexity. The only challenge is to devise an unambiguous syntax that doesn't clash with anything already existing in **_EasyCoder_**
71
72
 
@@ -48,13 +48,14 @@ Here in the repository is a folder called `scripts` containing some sample scrip
48
48
  `tests.ecs` is a test program containing many of the EasyCoder features
49
49
  `fizzbuzz.ecs` is a simple programming challenge often given at job interviews
50
50
 
51
- ## The EasyCoder programming language
52
- There are three primary components to the language:
53
-
54
- - Keywords
55
- - Values
56
- - Conditions
51
+ ## EasyCoder programming reference
57
52
 
58
53
  The language comprises a general-purpose core package, which can be enhanced by plugins to provide special features on demand.
59
54
 
60
- [The core package](doc/core.md)
55
+ [The core package](doc/README.md)
56
+
57
+ ## Extending the language
58
+
59
+ **_EasyCoder_** can be extended to add new functionality with the use of 'plugins'. These contain compiler and runtime modules for the added language features. **_EasyCoder_** can use the added keywords, values and conditions freely; the effect is completely seamless. There is an outline example in the `plugins` directory called `example.py`, which comprises a module called `Points` with new language syntax to deal with two-valued items such as coordinates. In the `scripts` directory there is `points.ecs`, which exercises the new functionality.
60
+
61
+ A plugin can act as a wrapper around any Python functionality that has a sensible API, thereby hiding its complexity. The only challenge is to devise an unambiguous syntax that doesn't clash with anything already existing in **_EasyCoder_**
@@ -1,5 +1,11 @@
1
1
  # The 'core' package
2
2
 
3
+ There are three primary components to the language:
4
+
5
+ - Keywords
6
+ - Values
7
+ - Conditions
8
+
3
9
  The core package contains all the keywords values and conditionals needed for general programming, and in most cases these are all that will be needed.
4
10
 
5
11
  The core keywords are:
@@ -10,3 +16,5 @@ The core values are:
10
16
 
11
17
 
12
18
  The core conditions are:
19
+
20
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Adds a numeric value to a numeric variable or adds two values and puts the resul
10
10
  Next: [append](append.md)
11
11
  Prev: [write](write.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Appends an item to a JSON array, which is is a string value held in a single var
10
10
  Next: [assert](assert.md)
11
11
  Prev: [add](add.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -8,4 +8,4 @@ Tests the condition and throws an exception if it is not true.
8
8
  Next: [begin](begin.md)
9
9
  Prev: [append](append.md)
10
10
 
11
- [Back](../core.md)
11
+ [Back](../README.md)
@@ -12,4 +12,4 @@
12
12
  Next: [clear](clear.md)
13
13
  Prev: [assert](assert.md)
14
14
 
15
- [Back](../core.md)
15
+ [Back](../README.md)
@@ -10,4 +10,4 @@
10
10
  Next: [close](close.md)
11
11
  Prev: [begin](begin.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -8,4 +8,4 @@ Close the file identified by the `{file}` variable. See `file`, `open`, `read` a
8
8
  Next: [create](create.md)
9
9
  Prev: [clear](clear.md)
10
10
 
11
- [Back](../core.md)
11
+ [Back](../README.md)
@@ -8,4 +8,4 @@ Create a directory, giving the full path in `{name}`.
8
8
  Next: [debug](debug.md)
9
9
  Prev: [close](close.md)
10
10
 
11
- [Back](../core.md)
11
+ [Back](../README.md)
@@ -13,4 +13,4 @@ Set up a debug option.
13
13
  Next: [decrement](decrement.md)
14
14
  Prev: [create](create.md)
15
15
 
16
- [Back](../core.md)
16
+ [Back](../README.md)
@@ -8,4 +8,4 @@ Decrements the value of the variable by 1. See also [increment](increment.md)
8
8
  Next: [delete](delete.md)
9
9
  Prev: [debug](debug.md)
10
10
 
11
- [Back](../core.md)
11
+ [Back](../README.md)
@@ -13,4 +13,4 @@ The second form deletes a named property of an object. See also [set property](s
13
13
  Next: [divide](divide.md)
14
14
  Prev: [decrement](decrement.md)
15
15
 
16
- [Back](../core.md)
16
+ [Back](../README.md)
@@ -11,4 +11,4 @@ Divides a numeric variable by a numeric value or divides one value by another an
11
11
  Next: [exit](exit.md)
12
12
  Prev: [delete](delete.md)
13
13
 
14
- [Back](../core.md)
14
+ [Back](../README.md)
@@ -8,4 +8,4 @@ Terminate the program.
8
8
  Next: [file](file.md)
9
9
  Prev: [divide](divide.md)
10
10
 
11
- [Back](../core.md)
11
+ [Back](../README.md)
@@ -11,4 +11,4 @@ Declare a file variable. See [open](open.md), [read](read.md), [write](write.md)
11
11
  Next: [fork](fork.md)
12
12
  Prev: [exit](exit.md)
13
13
 
14
- [Back](../core.md)
14
+ [Back](../README.md)
@@ -10,4 +10,4 @@ When `fork` is used, the forked commands run until they reach a [stop](stop.md)
10
10
  Next: [get](get.md)
11
11
  Prev: [exit](exit.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -12,4 +12,4 @@ Perform an HTTP GET to request data. In the second example, if the request fails
12
12
  Next: [gosub](gosub.md)
13
13
  Prev: [fork](fork.md)
14
14
 
15
- [Back](../core.md)
15
+ [Back](../README.md)
@@ -10,4 +10,4 @@
10
10
  Next: [gosub](gosub.md)
11
11
  Prev: [get](get.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -9,4 +9,4 @@
9
9
  Next: [if](if.md)
10
10
  Prev: [go](go.md)
11
11
 
12
- [Back](../core.md)
12
+ [Back](../README.md)
@@ -11,4 +11,4 @@
11
11
  Next: [increment](increment.md)
12
12
  Prev: [gosub](gosub.md)
13
13
 
14
- [Back](../core.md)
14
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Add 1 to the value of the variable. See also [decrement](decrement.md).
10
10
  Next: [index](index.md)
11
11
  Prev: [if](if.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -12,4 +12,4 @@
12
12
  Next: [init](init.md)
13
13
  Prev: [increment](increment.md)
14
14
 
15
- [Back](../core.md)
15
+ [Back](../README.md)
@@ -11,4 +11,4 @@
11
11
  Next: [input](input.md)
12
12
  Prev: [index](index.md)
13
13
 
14
- [Back](../core.md)
14
+ [Back](../README.md)
@@ -10,4 +10,4 @@
10
10
  Next: [multiply](multiply.md)
11
11
  Prev: [init](init.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -11,4 +11,4 @@ Multiplies a numeric variable by a numeric value or multiplies one value by anot
11
11
  Next: [open](open.md)
12
12
  Prev: [input](input.md)
13
13
 
14
- [Back](../core.md)
14
+ [Back](../README.md)
@@ -22,4 +22,4 @@ Opens a disk file for reading, writing or appending. Each of the [file](file.md)
22
22
  Next: [pop](pop.md)
23
23
  Prev: [multiply](multiply.md)
24
24
 
25
- [Back](../core.md)
25
+ [Back](../README.md)
@@ -9,4 +9,4 @@ Pops the top value from the specified [stack](stack.md).
9
9
  Next: [post](post.md)
10
10
  Prev: [open](open.md)
11
11
 
12
- [Back](../core.md)
12
+ [Back](../README.md)
@@ -14,4 +14,4 @@ Perform an HTTP PUT request with the specified data and endpoint, optionally sav
14
14
  Next: [print](print.md)
15
15
  Prev: [pop](pop.md)
16
16
 
17
- [Back](../core.md)
17
+ [Back](../README.md)
@@ -11,4 +11,4 @@ The output is prefixed by the script line number of the print command. This is v
11
11
  Next: [push](push.md)
12
12
  Prev: [post](post.md)
13
13
 
14
- [Back](../core.md)
14
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Push something onto the specified [stack](stack.md).
10
10
  Next: [put](put.md)
11
11
  Prev: [print](print.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Put a value into a [variable](variable.md). The second example illustrates how t
10
10
  Next: [read](read.md)
11
11
  Prev: [push](push.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -9,4 +9,4 @@ Read a value from a [file](file.md). See [open](open.md), [write](write.md) and
9
9
  Next: [replace](replace.md)
10
10
  Prev: [put](put.md)
11
11
 
12
- [Back](../core.md)
12
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Replaces all occurrences of one string with another in a string [variable](varia
10
10
  Next: [return](return.md)
11
11
  Prev: [read](read.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -9,4 +9,4 @@ Return from a subroutine. See [gosub](gosub.md).
9
9
  Next: [script](script.md)
10
10
  Prev: [replace](replace.md)
11
11
 
12
- [Back](../core.md)
12
+ [Back](../README.md)
@@ -9,4 +9,4 @@ Provides a name for the script. Note that `name` is literal text, not a script v
9
9
  Next: [set](set.md)
10
10
  Prev: [return](return.md)
11
11
 
12
- [Back](../core.md)
12
+ [Back](../README.md)
@@ -22,4 +22,4 @@
22
22
  Next: [split](split.md)
23
23
  Prev: [script](script.md)
24
24
 
25
- [Back](../core.md)
25
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Split a [variable](variable.md) containing a string into a number of parts on a
10
10
  Next: [stack](stack.md)
11
11
  Prev: [set](set.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Declares a stack variable, a special kind of array that permits elements to be [
10
10
  Next: [stop](stop.md)
11
11
  Prev: [split](split.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -12,4 +12,4 @@ Stop execution of the current thread. The program will not exit as there may be
12
12
  Next: [system](system.md)
13
13
  Prev: [stack](stack.md)
14
14
 
15
- [Back](../core.md)
15
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Issue a command to the operating system.
10
10
  Next: [take](take.md)
11
11
  Prev: [stop](stop.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -12,4 +12,4 @@ Subtracts a numeric value from a numeric variable or subtracts one value from an
12
12
  Next: [toggle](toggle.md)
13
13
  Prev: [system](system.md)
14
14
 
15
- [Back](../core.md)
15
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Toggle - change from `true` to `false` or vice versa - a variable that has been
10
10
  Next: [variable](variable.md)
11
11
  Prev: [take](take.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -11,4 +11,4 @@ Truncate a file
11
11
  Next: [variable](variable.md)
12
12
  Prev: [toggle](toggle.md)
13
13
 
14
- [Back](../core.md)
14
+ [Back](../README.md)
@@ -12,4 +12,4 @@ Variables can be assigned any number of elements - see [set the elements](set.md
12
12
  Next: [wait](wait.md)
13
13
  Prev: [toggle](toggle.md)
14
14
 
15
- [Back](../core.md)
15
+ [Back](../README.md)
@@ -15,4 +15,4 @@ By "thread" we mean the pseudo-threads **_EasyCoder_** uses to simulate multi-ta
15
15
  Next: [while](while.md)
16
16
  Prev: [variable](variable.md)
17
17
 
18
- [Back](../core.md)
18
+ [Back](../README.md)
@@ -17,4 +17,4 @@ When constructing loops like this it's common for programmers to forget to bump
17
17
  Next: [write](write.md)
18
18
  Prev: [wait](wait.md)
19
19
 
20
- [Back](../core.md)
20
+ [Back](../README.md)
@@ -10,4 +10,4 @@ Write a value to a [file](file.md). See [open](open.md), [read](read.md) and [cl
10
10
  Next: [add](add.md)
11
11
  Prev: [while](while.md)
12
12
 
13
- [Back](../core.md)
13
+ [Back](../README.md)
@@ -9,4 +9,4 @@ from .ec_program import *
9
9
  from .ec_timestamp import *
10
10
  from .ec_value import *
11
11
 
12
- __version__ = "241211.2"
12
+ __version__ = "241211.3"
@@ -9,11 +9,14 @@ class FatalError:
9
9
  sys.exit()
10
10
 
11
11
  class AssertionError:
12
- def __init__(self, program):
12
+ def __init__(self, program, msg=None):
13
13
  code = program.code[program.pc]
14
14
  lino = code['lino']
15
15
  script = program.script.lines[lino].strip()
16
- print(f'Assertion Error in {program.name} at line {lino + 1}')
16
+ message = f'Assertion Error in {program.name} at line {lino + 1}'
17
+ if msg != None:
18
+ message += f': {msg}'
19
+ print(message)
17
20
  sys.exit()
18
21
 
19
22
  class RuntimeError:
@@ -1640,7 +1640,7 @@ class Core(Handler):
1640
1640
  return value
1641
1641
  return None
1642
1642
 
1643
- print(f'Unknown token {token}')
1643
+ self.warning(f'Core: Unknown token {token}')
1644
1644
  return None
1645
1645
 
1646
1646
  #############################################################################
@@ -0,0 +1,90 @@
1
+ from easycoder import Handler, FatalError, RuntimeError, math
2
+
3
+ class Points(Handler):
4
+
5
+ def __init__(self, compiler):
6
+ Handler.__init__(self, compiler)
7
+
8
+ def getName(self):
9
+ return 'points'
10
+
11
+ #############################################################################
12
+ # Keyword handlers
13
+
14
+ def k_point(self, command):
15
+ return self.compileVariable(command, False)
16
+
17
+ def r_point(self, command):
18
+ return self.nextPC()
19
+
20
+ # set {point} to {xvalue} {yvalue}
21
+ def k_set(self, command):
22
+ if self.nextIsSymbol():
23
+ pointRecord = self.getSymbolRecord()
24
+ if pointRecord['keyword'] == 'point':
25
+ if self.nextIs('to'):
26
+ xValue = self.nextValue()
27
+ yValue = self.nextValue()
28
+ command['x'] = xValue
29
+ command['y'] = yValue
30
+ command['name'] = pointRecord['name']
31
+ self.add(command)
32
+ return True
33
+
34
+ def r_set(self, command):
35
+ pointRecord = self.getVariable(command['name'])
36
+ x = self.getRuntimeValue(command['x'])
37
+ y = self.getRuntimeValue(command['y'])
38
+ pointRecord['x'] = x
39
+ pointRecord['y'] = y
40
+ return self.nextPC()
41
+
42
+ #############################################################################
43
+ # Compile a value in this domain
44
+ def compileValue(self):
45
+ value = {}
46
+ value['domain'] = 'points'
47
+ if self.tokenIs('the'):
48
+ self.nextToken()
49
+ token = self.getToken()
50
+ if token == 'distance':
51
+ if self.nextIs('between'):
52
+ if self.nextIsSymbol():
53
+ point1Record = self.getSymbolRecord()
54
+ if point1Record['keyword'] == 'point':
55
+ if self.nextIs('and'):
56
+ if self.nextIsSymbol():
57
+ point2Record = self.getSymbolRecord()
58
+ if point2Record['keyword'] == 'point':
59
+ value['type'] = 'difference'
60
+ value['point1'] = point1Record['name']
61
+ value['point2'] = point2Record['name']
62
+ return value
63
+ return None
64
+
65
+ #############################################################################
66
+ # Modify a value or leave it unchanged.
67
+ def modifyValue(self, value):
68
+ return value
69
+
70
+ #############################################################################
71
+ # Value handlers
72
+
73
+ def v_difference(self, v):
74
+ point1 = self.getVariable(v['point1'])
75
+ point2 = self.getVariable(v['point2'])
76
+ dx = point2['x'] - point1['x']
77
+ dy = point2['y'] - point1['y']
78
+ value = {}
79
+ value['type'] = 'int'
80
+ value['content'] = int(math.sqrt(dx*dx + dy*dy))
81
+ return value
82
+
83
+ #############################################################################
84
+ # Compile a condition
85
+ def compileCondition(self):
86
+ condition = {}
87
+ return condition
88
+
89
+ #############################################################################
90
+ # Condition handlers
@@ -0,0 +1,16 @@
1
+ ! Points example
2
+
3
+ script Points
4
+
5
+ import Points from plugins/example.py
6
+
7
+ point Point1
8
+ point Point2
9
+ variable Distance
10
+
11
+ set Point1 to 50 500
12
+ set Point2 to 200 300
13
+
14
+ put the distance between Point1 and Point2 into Distance
15
+ assert Distance is 250 with `Distance is ` cat Distance cat `: should be 250`
16
+ print `The distance is ` cat Distance cat ` units`
File without changes
File without changes