header_utils
Loading...
Searching...
No Matches
Eval

A very simple Lisp-based scripting system useful pretty much only for scripting translation strings. More...

Classes

struct  ghassanpl::eval::value
 Represents a single evaluated value; can store an rvalue (as json), an lvalue (json*), or a (const) reference (json const*); lvalues and refs are used purely in function arguments. More...
struct  ghassanpl::eval::environment< DECADE_SYNTAX >
 The primary class to store the evaluation environment, declared functions, variables, etc. More...
struct  ghassanpl::eval::lib_core< DECADE_SYNTAX >
 Used with ghassanpl::eval::environment::import_lib() to add functions for basic decade to an eval environment. More...

Detailed Description

A very simple Lisp-based scripting system useful pretty much only for scripting translation strings.

Warning
This is severly undertested!

The system uses the json class to store values, so it's not condusive to too complex systems. A lot of operations are done by copying values around, so the performance is also sub-optimal, although some effort was put into allowing references to be passed in some places, to improve performance.

Specifically, global variables can only store pure JSON values, without embedded references.

Two syntaxes are available: sexps and decade. Sexps is the lisp (Polish Notation) syntax; Decade is my own custom syntax variant, which allows for smalltalk-style infix notation:

[a + b + c] -> func: ':+*':, args: a, b, c
[set a to b] -> func: 'set:to:', args: a, b
constexpr CONTAINER to(RANGE &&range, TYPES &&... args)
to<container>();
Definition ranges.h:386

Note that Decade syntax is slower to execute.

The semantics are closest to MDL, a Lisp flavor where you need to explicitly request the value of a variable using a prefix (.var).