From a78e132b721def48d22039ee25b7dacfb3519829 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Mon, 16 Sep 2024 12:50:05 -0700 Subject: [PATCH] Add better documentation --- README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++---------- web.lisp | 2 +- 2 files changed, 59 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6a87b0b..4f1db39 100644 --- a/README.md +++ b/README.md @@ -12,26 +12,20 @@ This repository contains three things: a Common Lisp library to parse and manipulate propositional logic expressions, a command line truth table generator, and a web-based truth table generator. -To build the CLI version, just run `make`. You will need SBCL, ASDF, and -Quicklisp. Quicklisp is used to load `uiop` and `with-user-abort`. +Building the CLI executable requires SBCL. Both the CLI and web server need +Quicklisp. If you have Quicklisp installed, it should just get the rest of the +dependencies for you. -To run the web server, execute `./truth-table-web-wrapper`. If you want to run -it in the background, I recommend using something like GNU Screen. The web -server supports `-h` and `--help`, you can use them to see all the options it -supports. It should be noted, however, that it does not support HTTPS. If you -want to use HTTPS, run the web server behind something like Nginx or HAProxy. +### CLI -The format of the input propositions is fairly free-form. The above Wikipedia -article has some information about their format, as well as possible symbols for -operators. You can also take a look at the table near the top of `parse.lisp` -for all the variations supported by this program. +To build the CLI version, just run `make`. -### CLI Usage -Here is the help output from the CLI (not web) program: +Here is the help output from the CLI program: ```text usage: truth-table [options] -h, --help print this message, then exit + --syntax-help print a syntax help message, then exit -f, --format= specify the output format (*unicode*, ascii, latex, or html) -s, --subexps include sub-expressions in the output table -n, --no-vars do not include variables in the output table @@ -56,3 +50,54 @@ $ truth-table '(a /\ b) -> ~b' │ ⊥ │ ⊥ │ ⊤ │ └───┴───┴────────────┘ ``` + +### Web + +To run the web server, execute `./truth-table-web-wrapper`. If you want to run +it in the background, I recommend using something like GNU Screen. It should be +noted, however, that it does not support HTTPS. If you want to use HTTPS, run +the web server behind something like Nginx or HAProxy. + +Here is the help output for the web wrapper program: +```text +usage: truth-table-web-wrapper [options] + + -h, --help print this message, then exit + -d, --debug enable debug output + -p, --port= specify port to use (default: 8000) + -a, --address= specify address to bind to (default: 127.0.0.1) + +Arguments to long options are also required for their short variant. +``` + +### Syntax +Here is the syntax for propositions (this is the same for both the web server +and the CLI): +```text +$ truth-table --syntax-help +┌───────────────────┬────────────────────────────────────────────┐ +│ Operator │ Syntax │ +├───────────────────┼────────────────────────────────────────────┤ +│ open parenthesis │ ( │ +│ close parenthesis │ ) │ +│ and │ &, &&, ., /\, and, ∧ │ +│ nand │ !&, !&&, nand, ~&, ~&&, ↑, ⊼ │ +│ or │ +, \/, or, |, ||, ∥, ∨ │ +│ nor │ !|, !||, nor, ~|, ~||, ↓, ⊽ │ +│ exclusive or │ !=, ^, xor, ↮, ≢, ⊕, ⊻ │ +│ not │ !, not, ~, ¬ │ +│ implies │ ->, =>, >, implies, →, ⇒, ⊃, ⟹ │ +│ converse │ <, <-, <=, converse, ←, ⇐, ⊂, ⟸ │ +│ biconditional │ <->, <=>, <>, =, ==, iff, xnor, ↔, ⇔, ≡, ⊙ │ +└───────────────────┴────────────────────────────────────────────┘ +┌─────────┬────────────────┐ +│ Operand │ Syntax │ +├─────────┼────────────────┤ +│ true │ 1, t, true, ⊤ │ +│ false │ 0, f, false, ⊥ │ +└─────────┴────────────────┘ +Two operands next to each other is treated as an 'implicit and' (unless this +feature is disabled). +Example: + abc|d = a ∧ b ∧ c ∨ d +``` diff --git a/web.lisp b/web.lisp index 36fbcc6..9230f5f 100644 --- a/web.lisp +++ b/web.lisp @@ -509,7 +509,7 @@ arguments." (cerror "Ignore the extra arguments." 'command-line-error :message "extra non-option arguments")) (when (option-value 'help opts) - (print-usage t *command-line-spec* "truth-table-webserver" + (print-usage t *command-line-spec* "truth-table-web-wrapper" :print-astrisk nil) (if cmdline-error (uiop:quit 1)