From 8f6717d7db9f6058b4be944c5bf562ee065d4f20 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Thu, 4 Jan 2024 12:09:25 +0100 Subject: [PATCH] more docs --- .gitignore | 1 + .idea/misc.xml | 1 + README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 7f5275b..2863a0b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ # CMake cmake-build-*/ +build/ # Mongo Explorer plugin .idea/**/mongoSettings.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index 18fd82f..8c83e32 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,7 @@ + diff --git a/README.md b/README.md index a8e5a22..dd949d7 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ cmake --build build --parallel $(nproc) should be enough (you can also change the build type for Release and disable sanitize in case it's too slow) +Pro-tip: all these snippets can be conveniently run from an IDE if it supports it (at least clion does) + ## How to run tests Unit tests (assuming build in `build`): @@ -29,7 +31,7 @@ PSIL="../build/src/psil" clitests/testall.sh # How to use -You can just run the executable and you'll be in REPL mode, +You can just run the executable and you'll be in REPL mode (ctrl-c to exit should work), or specify an input file like `-f `, the effect is the same as if you had put it there yourself. @@ -39,12 +41,50 @@ When reading from a file, REPL is still enabled by default and can be disabled w You can also change some of the behaviours of the interpreter: +`--cell_limit:limit` (for example `--cell_limit:10000`) - limit the amount of cells that can be used + +`--command_strs[+/-]` (for example `--command_strs+`) - use string representation of commands, useful for debugging the +compiler with verbose logging + +`--default_log_level:level` (for example `--default_log_level:3`) - change the default logging level + +`--repl[+/-]` (for example `--repl-`) - enable/disable repl + +`--gc_threshold:threshold` (for example `--gc_threshold:70`) - percentage of cell_limit at which concurrent gc is +triggered + +### Log options + +Log can be configured in format of `--log:TAG:LEVEL` (for example `--log:VM:3`) + +Where level is a number from 0 to 4 (0 - no logs, 4 - most logs) + +Possible values for tags are: + +`MemoryContext` - at level 2 it will print GC stats for each run, level 3 a little more stats, level 4 is debugging mode + +`Compiler` - level 3 will print the compilation result of everything evaluated, you also probably want to +have `--command_strs+` enabled with it + +`VM` - level 3 will print function application and return info, level 4 is debugging mode which will print every +instruction and the machine state before/after + +# Some cooler examples + +See the GC in action: + ```shell ---cell_limit:limit (for example --cell_limit:10000) - limit the amount of cells that can be used ---command_strs[+/-] (for example --command_strs+) - use string representation of commands, useful - for debugging the compiler with verbose logging ---default_log_level:level (for example --default_log_level:3) - change the default logging level ---repl[+/-] (for example --repl-) - enable/disable repl +build/src/psil -f clitests/fib.psil --repl- --log:Compiler:3 --command_strs+ --cell_limit:10000 --gc_threshold:10 --log:MemoryContext:2 ``` +See a tree of function applications: +```shell +build/src/psil -f clitests/coffee.psil --repl- --log:Compiler:3 --command_strs+ --log:VM:3 +``` + +Super debug mode: + +```shell +build/src/psil -f clitests/decorate.psil --repl- --command_strs+ --default_log_level:4 --log:MemoryContext:3 +``` \ No newline at end of file