A simple embeddable scripting language.
Matthias Ladkau b986226dc7 doc: Cleanup of documentation | 4 years ago | |
---|---|---|
cli | 4 years ago | |
config | 4 years ago | |
ecal-support | 4 years ago | |
engine | 4 years ago | |
examples | 4 years ago | |
interpreter | 4 years ago | |
parser | 4 years ago | |
scope | 4 years ago | |
stdlib | 4 years ago | |
util | 4 years ago | |
.gitignore | 4 years ago | |
LICENSE | 4 years ago | |
Makefile | 4 years ago | |
NOTICE | 4 years ago | |
README.md | 4 years ago | |
debug.md | 4 years ago | |
ecal.md | 4 years ago | |
engine.md | 4 years ago | |
go.mod | 4 years ago | |
go.sum | 4 years ago |
ECAL is an ECA (Event Condition Action) language for concurrent event processing. ECAL can define event-based systems using rules which are triggered by events. ECAL is intended to be embedded into other software to provide an easy to use scripting language which can react to external events.
Clone the repository and build the ECAL executable with a simple make
command. You need Go 1.14 or higher.
Run ./ecal
to start an interactive session. You can now write simple one line statements and evaluate them:
>>>a:=2;b:=a*4;a+b
10
>>>"Result is {{a+b}}"
Result is 10
Close the interpreter by pressing +d and change into the directory examples/fib
.
There are 2 ECAL files in here:
lib.ecal
# Library for fib
/*
fib calculates the fibonacci series using recursion.
*/
func fib(n) {
if (n <= 1) {
return n
}
return fib(n-1) + fib(n-2)
}
fib.ecal
import "lib.ecal" as lib
for a in range(2, 20, 2) {
log("fib({{a}}) = ", lib.fib(a))
}
Run the ECAL program with: sh run.sh
. The output should be like:
$ sh run.sh
2000/01/01 12:12:01 fib(2) = 1
2000/01/01 12:12:01 fib(4) = 3
2000/01/01 12:12:01 fib(6) = 8
2000/01/01 12:12:01 fib(8) = 21
2000/01/01 12:12:01 fib(10) = 55
2000/01/01 12:12:01 fib(12) = 144
2000/01/01 12:12:02 fib(14) = 377
2000/01/01 12:12:02 fib(16) = 987
2000/01/01 12:12:02 fib(18) = 2584
2000/01/01 12:12:02 fib(20) = 6765
The interpreter can be run in debug mode which adds debug commands to the console. Run the ECAL program in debug mode with: sh debug.sh
- this will also start a debug server which external development environments can connect to. There is a VSCode integration available which allows debugging via a graphical interface.
ECAL source code is available under the MIT License.