Minor docs update.

This commit is contained in:
Simon Forman 2019-12-02 14:13:50 -08:00
parent eb591d27e0
commit 57446a1179
2 changed files with 15 additions and 9 deletions

View File

@ -35,12 +35,15 @@ from .utils.pretty_print import TracePrinter
def joy(stack, expression, dictionary, viewer=None):
'''Evaluate the Joy expression on the stack.
'''Evaluate a Joy expression on a stack.
The basic joy() function is quite straightforward. It iterates through a
sequence of terms which are either literals (strings, numbers, sequences)
or functions. Literals are put onto the stack and functions are
executed.
This function iterates through a sequence of terms which are either
literals (strings, numbers, sequences of terms) or function symbols.
Literals are put onto the stack and functions are looked up in the
disctionary and executed.
The viewer is a function that is called with the stack and expression
on every iteration, its return value is ignored.
:param stack stack: The stack.
:param stack expression: The expression to evaluate.

View File

@ -26,11 +26,14 @@ by the fact that they are not Symbol objects.
A crude grammar::
joy = term*
term = int | float | string | '[' joy ']' | function
A Joy expression is a sequence of zero or more terms
joy = term*
term = int | float | string | '[' joy ']' | symbol
A Joy expression is a sequence of zero or more terms. A term is a
literal value (integer, float, string, or Joy expression) or a function
symbol. Function symbols are unquoted strings and cannot contain square
brackets. Terms must be separated by blanks, which can be omitted
around square brackets.
'''
#TODO: explain the details of float lits and strings.