Updated readme's, add prototype function declaration operation

This commit is contained in:
Aidan 2020-07-04 20:41:10 -07:00
parent c90d445d7d
commit 19a16d8de0
No known key found for this signature in database
GPG key ID: 327711E983899316
5 changed files with 137 additions and 4 deletions

View file

@ -47,18 +47,25 @@ See `stdlib/control_flow.go`. We have if and while forms:
`(if (cond) (then) (else))`
`(when (cond) (form1)....... (formN))`
We also have functioning implementations of map and reduce in the stdlib
We also have functioning implementations of map and reduce in the stdlib (incomplete)
## How to build
### Compiling/Installation
- For now simply run `go install cmd/...` for each utility you wish to use. If you have GOPATH and GOBIN set it should be usable from PATH
### Adding SHS to your application
- TODO: write a how to here
* Make sure to set ast.SyncTablesWithOSEnviron, ast.ExecWhenFuncUndef. All of which control integrations with the underlying system.
- If you do not want the user to be able to set environment variables set ast.SyncTablesWithOSEnviron to false.
- If you do not want the user to be able to call binaries from the host system, set ast.ExecWhenFuncUndef to false.
- Get text you are interested in parsing
- Create a new VarTable and FuncTable (see ast/var_table.go and ast/func_table.go)
- Call `Lex(text)` on the `text` you want to evaluate to recieve a tree of parsed lexemes.
- Call `tree.Eval(FuncTable, VarTable, false)` where tree is the returned data from Lex, and the final boolean argument is whether or not to convert unknown symbols to strings. (this is a helpful option if you are writing functions such as those in stdlib/call.go, or any funciton in which you may want to be able to edit and transform the final ast based on your own varaiable table)
- Make sure the GPLv3 is adhered to
- *OVERRIDE THE STDLIB GenFuncTable FUNCTION.* You very likely do NOT want an available function to call system binaries in your embedded shell. Make sure the stdlib Call function is not included.
## Configuration
* variables exported in the repl, if of types string or number, will result in a corresponding variable added to the Environment.
* one can write arbitrary shs script into `.shsrc` including function and variable declarations
* of note are the following variables
- `SH_LOGGING` Sets the log level (from 0 to 3)
@ -72,7 +79,7 @@ Here is an example of a shs configuration file:
(export "PATH" (concat PATH ":" GOBIN))
(export "GIT_TERMINAL_PROMPT" 1)
(export "SH_HIST_FILE" (concat HOME "/.shs_hist"))
(export "SH_LOGGING" 3)
(export "SH_LOGGING" 0)
```
## Contributing