A simple embeddable scripting language.

Matthias Ladkau e2b396579d fix: VSCode extension cleanup il y a 3 ans
cli c452e78b74 fix: Proper restarting of interpreter state when debugger starts il y a 3 ans
config 840f1e1958 feat: Adding logging and sink support il y a 3 ans
ecal-support e2b396579d fix: VSCode extension cleanup il y a 3 ans
engine a9c9f2eb92 feat: Adding reload support il y a 3 ans
examples e2b396579d fix: VSCode extension cleanup il y a 3 ans
interpreter c452e78b74 fix: Proper restarting of interpreter state when debugger starts il y a 3 ans
parser 0eda3e5bc3 feat: Adding local variable declaration via let il y a 3 ans
scope 0eda3e5bc3 feat: Adding local variable declaration via let il y a 3 ans
stdlib 490ce0bb0f feat: Add thread IDs il y a 3 ans
util c452e78b74 fix: Proper restarting of interpreter state when debugger starts il y a 3 ans
.gitignore ecfaf8048d feat: Adding initial parts for debug support il y a 3 ans
LICENSE 7ae4036818 feat: Adding initial skeleton il y a 3 ans
Makefile 7975b738af feat: CLI support il y a 3 ans
NOTICE 7ae4036818 feat: Adding initial skeleton il y a 3 ans
README.md 82d27f1fb3 doc: Adding getting started il y a 3 ans
debug.md ecfaf8048d feat: Adding initial parts for debug support il y a 3 ans
ecal.md 0eda3e5bc3 feat: Adding local variable declaration via let il y a 3 ans
engine.md 840f1e1958 feat: Adding logging and sink support il y a 3 ans
go.mod 63811157fa fix: Better debug display for variable scopes il y a 3 ans
go.sum 63811157fa fix: Better debug display for variable scopes il y a 3 ans

README.md

ECAL

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.

Features

  • Simple intuitive syntax
  • Minimalistic base language
  • Language can be easily extended either by auto generating bridge adapters to Go functions or by adding custom function into the stdlib
  • External events can be easily pushed into the interpreter and scripts written in ECAL can react to the events.
  • Simple but powerful concurrent event-based processing supporting priorities and scoping for control flow.
  • Handling event rules can match on event state and rules can suppress each other.

Getting started

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

Further Reading:

License

ECAL source code is available under the MIT License.