Shell documentation
index:
Presentation:
The shell is an interpreted stack based language similar to forth. (Datas are stored into a lifo stack)
The difference with forth are:
When executing an error is produced if:
Note:
Stack use:
output: Hellow world
output: Value = 100
output: Value = 50
Variable definition:
To declare or set variable value, use char '!'
A new variable is declared and initialized at same time
To write to existing variable, use char '!'(same as declare)
To read a variable, use char '.'
Note: To make difference with shell user functions (for readibility), variable name must not start with '_' char.
ex 4
output : Value = 100
Function call:
A shell function is declared with char ':'
To call a shell function, use char '_' preceding function name.
ex 5 (function call without parameters)
output : Hello World
Function parameters:
Function parameters must be declared using '%' char + parameter type.
Function can return only one value on stack if 'return' keyword is used.
Actually, function parameters types can be:
note: The parameters type declaration must have same order than datas on stack
ex 6 (function call with parameters)
output : Result = -10
ex 7 (function call with named parameters)
To increase readibility, function parameters can be named. This must be done immediatly when entering in function bloc on the first line.
output : Sub (Hello) = 80
Tests:
keywords used for test are :
ex 8
output : a <= b
Loops:
keywords used for loops are:
ex 9
output : 1, 2, 9, 10,
Command line execute:
Command line functions can be executed as if it was typed directly on keyboard.
Use keyword 'cmd'
ex 10
This launch the command "printlog".
Because command line functions always return an integer value, to keep stack size = 0 at line end, the command returned value must be deleted (or can be used if required)
To delete the top stack value, use 'drop' command
Resume of keywords:
Keywords:
Operators:
Other operators same as C:
To be done: Add readkey keyword
Aspect of a more complicated shell source (test code doing test only)