Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: tweaks

...

The grammar used in the node pico engine can be perused at https://github.com/Picolab/pico-engine/blob/master/packages/krl-parser/src/grammar.ne, and is authoritative where it differs from the presentation here.

This page concentrates on the syntax of KRL, with numerous links to other pages which give examples and/or discuss run-time behavior.

Ruleset

In KRL, the ruleset is the unit of compilation, and also the smallest piece of functionality that can be installed in a pico.

...

This block is optional, but is generally present. The global block is a sequence of expressions which are evaluate as the ruleset is installed into a pico. The value of each expression is then bound to a name (the identifier on the left hand side of the equal sign). Names defined in the global block are in scope from their point of definition throughout the ruleset. There is no syntax (nor is there run-time support) for modification of the value bound to these names. This is similar to final in Java.

Besides use in the remainder of this ruleset, names can be shared with the outside world (by being named in the meta block shares entry). Names can also be provided to another ruleset which is using this ruleset as a module (by being named in the meta block provides entry).

Rules

Finally a ruleset may contain a sequence of rule definitions.

...

If a foreach is present, it will apply to the remainder of the rule, which will be evaluated once per item in the map or array computed by theĀ <EXPR>. Each time through the loop, the first identifier in the setting clause will have a value from the map or array, and the second identifier (if named) will have the corresponding key or index value.

...