67 lines
3.3 KiB
ReStructuredText
67 lines
3.3 KiB
ReStructuredText
Format Rules
|
|
============
|
|
|
|
|
|
Basic definition
|
|
****************
|
|
|
|
Format rules are rules that define how the result of the execution must be printed.
|
|
I guess that it will be ultimately be replaced / transformed into the program that can speak
|
|
|
|
|
|
::
|
|
|
|
> when <predicate> print <action>
|
|
|
|
where:
|
|
|
|
predicate is a valid sheerka syntax
|
|
|
|
action is a custom language defined below
|
|
|
|
|
|
Action
|
|
*******
|
|
|
|
::
|
|
|
|
ACTION := FUNCTION | VARIABLE | RAW
|
|
FUNCTION := IDENT \( PARAM* (, PARAM)* \)
|
|
PARAM :=
|
|
VARIABLE := \{PREFIX:IDENT \}
|
|
PREFIX :=
|
|
RAW :=
|
|
|
|
Some examples
|
|
|
|
::
|
|
|
|
blue(digest) : {command}\nlist(body)
|
|
|
|
|
|
Predicate
|
|
*********
|
|
The predicate indicates the conditions to trigger the print / formatting
|
|
You can use the whole Sheerka language (methods and Concepts)
|
|
|
|
In addition to the regular function, you have also access to local variables
|
|
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------+
|
|
| Name | Definition |
|
|
+=================+=========================================================================================================================+
|
|
| __obj | The current object being processed |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------+
|
|
| __ret | current object if it is a ``ReturnValueConcept`` |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------+
|
|
| __ret_value | |
|
|
| | * current value's body if the current value is a ``ReturnValueConcept`` |
|
|
| | * current value's body's body if the current value is a ``ReturnValueConcept`` and the body is a container concept |
|
|
| | * current value otherwise |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------+
|
|
| __ret_container | When the current value is a ``ReturnValueConcept`` and its body is a container concept such as |
|
|
| | * ``ParserResultConcept`` |
|
|
| | * ``ErrorConcept`` |
|
|
| | * ``OnlySuccessfulConcept`` |
|
|
| | * ... |
|
|
+-----------------+-------------------------------------------------------------------------------------------------------------------------+
|