diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/internal_functions_dictionary | 10 | ||||
| -rw-r--r-- | doc/precedent.1 | 81 |
2 files changed, 81 insertions, 10 deletions
diff --git a/doc/internal_functions_dictionary b/doc/internal_functions_dictionary deleted file mode 100644 index 5238098..0000000 --- a/doc/internal_functions_dictionary +++ /dev/null @@ -1,10 +0,0 @@ -root() -- executes all arguments. returns the eval of the last symbol -ref() -- returns its argument without evaluating it -eval() -- evaluates its first argument, passing the rest of its arguments into the eval of its first argument -store() -- stores a pointer to the first argument under the name specified by the eval of the second argument, within the local scope -update() -- same as store(), but tries to overwrite the value of an already stored key - if the current scope doesn't contain the key, checks upwards. if no scope contains the key, update() does nothing -eq() -- returns 1 if the eval of all the arguments is the same, 0 if different. accepts any number of arguments -if() -- if the eval of the first argument is 1, executes all the other arguments -not() -- if the eval of the first argument is 1, returns 0, and vice versa -sum() -- returns the sum of the eval of all the arguments -print() -- prints the eval of the first argument to the console, and a newline character diff --git a/doc/precedent.1 b/doc/precedent.1 new file mode 100644 index 0000000..6f7a9c4 --- /dev/null +++ b/doc/precedent.1 @@ -0,0 +1,81 @@ +.TH PRECEDENT 1 "23 Feb 21" "Precedent version 0.1" +.SH NAME +precedent \- simple interpreted language + +.SH SYNOPSIS +\fBprecedent\fP <file> [--visualize] [--debug] [--version] [--help] + +.SH DESCRIPTION +Precedent is an interpreted language. The syntax is extremely simple, +which lends to a writing in a functional paradigm. However, precedent also +supports imperative programming, with variable scoping and side-effects. +Precedent supports integers, floats, and strings, with basic functions +to manipulate each. Precedent has a simple pre-processor supporting +include statements, so libraries may be written to re-use code. + +.SH DICHOTOMY +Everything in precedent is a symbol. Every symbol is either a key or literal. +A literal may be an integer, a float, or a string, and is self-evaluating. +A key exists in some scope, and points to some symbol. There are default ("internal") +keys, and keys created with store(). A key may accept parameters, making it a function. + +.SH SYNTAX +Spaces, tabs, newlines, and other forms of whitespace are ignored. +A literal value is defined by its termination with a semicolon. The following +are examples of literal values: [ 123; hello world; 9.81; ]. A key is defined by its +termination with a pair of parentheses. The following are examples of key references: +[ myVar() arg0() ]. A key reference may have any number of arguments, which may be +literals or key references. The following are examples of key references with arguments: +[ print(hello world;) print(myVar()) print(eq(1; 2;)) ]. + +.SH FUNCTIONS +\fBroot() OR ()\fP +\-\- Executes all arguments. Returns the evaluation of the last symbol. Used to define a function. + +\fBref()\fP +\-\- Returns a pointer to its first argument, not evaluating it. + +\fBeval()\fP +\-\- Evaluates its first argument, passing the the rest of its arguments as arg0, arg1... etc. Essentially undoes ref(). + +\fBstore()\fP +\-\- Stores the evaluation of its first argument under the name specified by the (string) evaluation of its second argument. Use with ref() to store functions, or without to store variables. + +\fBupdate()\fP +\-\- Stores the evaluation of its first argument under the name specified by the (string) evaluation of its second argument, in the same manner as store(). Update() differs from store when the key is not found in the local scope. In this case, update() searches upwards for the first scope containing the key, and overwrites its value. + +\fBeq()\fP +\-\- Evaluates all of its arguments. If they are all equivalent, returns 1. Otherwise, returns 0. + +\fBif()\fP +\-\- If its first argument is not 0, evaluates the rest of its arguments. Does not return a value. + +\fBnot()\fP +\-\- If its first argument is 0, returns 1. Otherwise, returns 0. + +\fBsum()\fP +\-\- Evaluates all its arguments. Returns the sum. + +\fBprint()\fP +\-\- Evaluates its first argument and prints it to the terminal. + +.SS Options +\fB--help\fP +\-\- Displays usage info. + +\fB--version\fP +\-\- Displays version info, and license information. + +\fB--visualize\fP +\-\- Displays the the program structure before execution. + +\fB--debug\fP +\-\- Writes additional debug information. + +.SH AUTHOR +Developed and maintained by Kai Stevenson +See https://www.aberrantflux.xyz/cgit/precedent.git for the latest version +of the software. + +.SH "SEE ALSO" +c(7) |
