From 288727f09a1b3458c268497d111349e608c3f9fa Mon Sep 17 00:00:00 2001 From: "bozo.kopic" Date: Tue, 2 Aug 2022 01:20:12 +0200 Subject: init --- docs/eval.rst | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 docs/eval.rst (limited to 'docs/eval.rst') diff --git a/docs/eval.rst b/docs/eval.rst new file mode 100644 index 0000000..1e66698 --- /dev/null +++ b/docs/eval.rst @@ -0,0 +1,48 @@ +Evaluation +========== + +Because Lisp code is represented with data structures, each data structure +can be used as interpreter instruction. Evaluation of data, when used as +interpreter expression, is defined according to data type: + + * number, string, builtin function, builtin syntax, function, syntax + + Data of this type evaluate to itself (expression consisting of + single instance of data evaluates to provided data instance). + + * symbol + + Symbols evaluate to data associated to provided symbol in + current evaluation context. If context entry associated with the symbol + is not available, evaluation error is signaled. + + * pair/list + + Lists evaluate to function/syntax application. As first step, + first element of list is evaluated. If first element evaluates + to function or builtin function, all remaining elements are also + evaluated and used as provided arguments. If first element evaluates + to syntax or builtin syntax, remaining list elements are not evaluated + and are used as provided arguments. After evaluation of first element + and possible argument evaluation (in case of functions), evaluation + is delegated to function/syntax application (described in following + chapters). If first list element doesn't evaluate to function/syntax, + evaluation error is signaled. Exception to this rule is empty + list which evaluates to itself. + + +Source code +----------- + +eval.h +'''''' + +.. literalinclude:: ../src_c/eval.h + :language: c + + +eval.c +'''''' + +.. literalinclude:: ../src_c/eval.c + :language: c -- cgit v1.2.3-70-g09d2