Add syntax help menu and cli option
This commit is contained in:
71
parse.lisp
71
parse.lisp
@ -86,6 +86,77 @@ proposition."))
|
||||
(iff "<->" "<>" "<=>" "⇔" "↔" "≡" "iff" "=" "==" "xnor" "⊙"))
|
||||
"Alist table of operator symbols and their possible string representations.")
|
||||
|
||||
(defparameter *operator-descriptions* ;; noindent 30
|
||||
`((open-paren ("open parenthesis")
|
||||
,(format nil "Used in combination with a close parenthesis to denote ~
|
||||
some terms to be evaluated before the surrounding terms.")
|
||||
(((and (or true true) false) . false)
|
||||
((or true (and true false)) . true)))
|
||||
(close-paren ("close parenthesis")
|
||||
"Used to close a group started with an open parenthesis."
|
||||
()) ;; no examples for closed paren
|
||||
(and ("and" "conjunction")
|
||||
,(format nil "Evaluate to true only if the expressions to the left and ~
|
||||
right evaluate to true.")
|
||||
(((and true true) . true)
|
||||
((and true false) . false)))
|
||||
(nand ("nand" "non-conjunction")
|
||||
,(format nil "Evaluate to true unless the expressions to the left and ~
|
||||
right are both true. This is the negation of the 'and' operator.")
|
||||
(((nand true true) . false)
|
||||
((nand true false) . true)
|
||||
((nand false false) . true)))
|
||||
(or ("or" "disjunction")
|
||||
,(format nil "Evaluate to true if the expression to the left is true, the ~
|
||||
expression to the right is true, or both the left and right expressions are ~
|
||||
true.")
|
||||
(((or true true) . true)
|
||||
((or true false) . true)
|
||||
((or false false) . false)))
|
||||
(nor ("nor" "non-disjunction")
|
||||
,(format nil "Evaluate to true if the expressions to the left and right ~
|
||||
are both false. This is the negation of the 'or' operator.")
|
||||
(((nor true true) . false)
|
||||
((nor true false) . false)
|
||||
((nor false false) . true)))
|
||||
(xor ("exclusive or" "exclusive disjunction") ;; noindent 30
|
||||
,(format nil "Evaluate to true if the expression to the left is true or ~
|
||||
if the expression to the right is true, but not if both of them are true.")
|
||||
(((xor true true) . false)
|
||||
((xor true false) . true)))
|
||||
(not ("not" "negation")
|
||||
,(format nil "Evaluate to false if the expression to the left evaluates ~
|
||||
to true, and evaluate to true if the expression to the left evaluates to ~
|
||||
false. This is a unary operator (it only applies to the expression following ~
|
||||
it).")
|
||||
(((not true) . false)
|
||||
((not false) . true)))
|
||||
(implies ("implies" "conditional")
|
||||
,(format nil "Evaluate to false if the expression to the left evaluates ~
|
||||
to true and the expressions to the right evaluates to false. Otherwise, ~
|
||||
evaluate to true.")
|
||||
(((implies true true) . true)
|
||||
((implies true false) . false)
|
||||
((implies false true) . true)
|
||||
((implies false false) . true)))
|
||||
(converse ("converse")
|
||||
,(format nil "Evaluate to false if the expression to the right evaluates ~
|
||||
to true and the expression to the left evaluates to false. Otherwise, evaluate ~
|
||||
to true. This is the 'implies' operator with its arguments flipped.")
|
||||
(((implies true true) . true)
|
||||
((implies true false) . true)
|
||||
((implies false true) . false)
|
||||
((implies false false) . true)))
|
||||
(iff ("biconditional" "equivalent")
|
||||
,(format nil "Evaluate to true if the expressions to the left and rigt ~
|
||||
evaluate to the same value. That is, they are both true or both false.")
|
||||
(((iff true true) . true)
|
||||
((iff true false) . false)
|
||||
((iff false false) . true))))
|
||||
"Alist table of operator symbols and their descriptions. The format of this
|
||||
list is SYMBOL NAMES DESCRIPTION (&rest (EXAMPLE LEFT . EXAMPLE RIGHT)). These
|
||||
are useful for use in things like syntax explanation messages.")
|
||||
|
||||
(defun operator-symbol (oper-str)
|
||||
"Return the symbol for OPER-STR, or nil if it is not a know operator."
|
||||
(loop for (oper-sym . strs) in *operator-symbol-table*
|
||||
|
Reference in New Issue
Block a user