summaryrefslogtreecommitdiff
path: root/doc/precedent.1
blob: a974cf84da681119ccec794771614ff50825a577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
.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 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 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 either a number or wrapped in quotation marks. The following
are examples of literal values: [ 123, "hello world", 9.81 ]. A key without arguments
is simply stated as a word. 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 and returns the sum. If any argument is a float, returns a float. Otherwise, returns an int.

\fBsub()\fP
\-\- Evaluates all its arguments. Subtracts every argument after the first from the first. Returns the result, which is a float if any arguments were floats, or an int if all arguments were ints.

\fBprint()\fP
\-\- Evaluates its first argument and prints it to the terminal.

.SH AUTHOR
Developed and maintained by Kai Stevenson.
See git.aberrantflux.xyz/precedent.git for the latest version
of the software.

.SH "SEE ALSO"
c(7)