Articles (Context-Dependent)#
| Keyword | Usage |
|---|---|
a, an | Declares new variable with type |
the | References existing variable |
Statement Starters#
| Keyword | Purpose |
|---|---|
Print | Output |
Set, Create | Variable declaration |
If, When | Conditional |
While | Loop |
For | Iteration |
To | Function definition |
Return | Return value |
Increment | Add 1 to variable |
Decrement | Subtract 1 from variable |
Break | Exit loop |
Continue | Skip to next iteration |
Exit | Terminate program with exit code |
Append | Add element to list |
Free | Release a buffer or list's memory immediately (see Releasing a Buffer) |
Allocate | Reserve a raw block of heap memory, freed with Free |
Create, Change, Remove/Delete | Directories, device nodes, symlinks, chdir (see Directories, Mounting, and Process Control) |
Mount, Unmount/Umount | Mount/unmount filesystems |
Pivot | pivot_root - switch the root filesystem |
Execute | execve - replace the process image |
Shutdown/Poweroff, Reboot/Restart, Halt | reboot(2) - power off/restart/halt the machine |
fork, reap | Process control expressions - fork(2)/wait4(2) |
Send signal | kill(2) - send a signal to a process, a process group, my process group, or every process (child aliases process) |
Read | Read from <file> into <buffer>. / Read line from <file> into <buffer>. |
Write | Write <value> to <file>. |
Open | open a file for reading/writing/appending called <name> at <path>. |
Close | Close <file>. |
Wait | Wait <n> seconds. / Wait <n> milliseconds. |
Sleep | Sleep for <n> seconds. / Sleep for <n> milliseconds. |
Get | Get current time into <name>. |
Clear | Set a buffer's length to 0, keeping its capacity (clear <buffer>.) |
Copy | Replace a buffer's contents with another's bytes (copy <source> to <destination>.) |
Resize | Change a buffer's capacity, preserving data up to the smaller of the two lengths (resize <buffer> to <n> bytes.) |
Seek | Move a file's read/write position (Seek <file> to line <n>. / Seek <file> to byte <n>.) |
Repeat | Loop a fixed number of times (Repeat <n> times, <statements>., see Repeat) |
See | Include another Vox source file, or consume a shared library's .lib interface (see The see Keyword) |
Library | Declare a shared library's name and version at the top of a .vox file (see Shared libraries) |
Flag Schema#
| Keyword | Purpose |
|---|---|
Flag | Declare a command-line flag schema (a flag called ...) |
Parse | Trigger command-line flag parsing (Parse flags.) |
Required | Mark a flag as required |
Default | Supply a default value for a flag |
Connectors#
| Keyword | Purpose |
|---|---|
with | Function parameters, function arguments |
called, named | Variable naming |
of, to, on | Function arguments |
and | Multiple uses (see below) |
or | Logical OR |
but | Conditional chaining |
then | After condition |
otherwise, else | Alternative branch |
from, to | Range bounds |
between | Range bound, inclusive of both ends (see Ranges) |
in | Collection/range membership (For each x in <list>) and unit casting (<timer>'s duration in seconds) |
into | Destination of Read from <file> into <buffer>. and Get current time into <name>. |
each | Universal loop expansion: turns any action into a loop (<action> each <var> from <collection>, see Loop Expansion) |
without | Suppresses the trailing newline (Print <x> without newline.); also the without waiting reap suffix |
as | Type-cast target (as a number) and substitution replacement (treating X as Y) |
treating | Inline value substitution (treating <match> as <replacement>, see Inline Substitution with treating) |
times | Loop-count unit in Repeat <n> times, <statements>. |
The and Keyword#
The word and has multiple context-dependent meanings:
| Context | Example | Meaning |
|---|---|---|
| Logical operator | if x and y then | Boolean AND of two conditions |
| Function parameters | with a number called x and a number called y | Separates parameter declarations |
| Function arguments | 'add' of 3 and 5 | Separates argument values |
| Subject list terminator | x, y, and z are true | Final item in comma-separated list before are |
Disambiguation:
- When
andappears after a comma and beforeare, it's a list terminator - When
andappears between two conditions (no comma), it's a logical operator - When
andfollowswith/of/to/on, it separates arguments
Types#
The type keywords, reserved as variable names for the same reason a statement starter is (see Types for what each one holds):
| Keyword | Purpose |
|---|---|
number | Integer type |
int | Alternate spelling of number (its alias integer is in the Reserved Aliases table below) |
float | Floating-point type |
text | String type |
boolean | Boolean type |
true, false | The two boolean literal values |
list | Collection type (see Lists and Collections) |
map | Key/value collection type (see Maps) |
buffer | Memory-block type for I/O (see Buffers) |
file | File descriptor handle type (see File I/O) |
time | Date/time value type (see Time and Timers) |
timer | Stopwatch type for measuring durations (see Timers) |
nothing | The absent value literal (see Nothing (the absent value)) |
Operators#
The operator keywords, fully defined in Operators:
| Keyword | Purpose |
|---|---|
add, subtract, multiply, divide, modulo | Arithmetic operators (x add 5, see Arithmetic) |
is, are, equals, greater, less, than | Comparison operators (x is greater than 5, see Comparisons) |
not | Logical negation (see Logical Operators) |
even, odd, positive, negative, zero, empty | Property-check predicates (the x is even, see Property Checks) |
bit-and, bit-or, bit-xor, bit-not, bit-shift-left, bit-shift-right | Bitwise operators (see Bitwise Operators) |
Reserved Aliases#
A few alternate spellings are also reserved because the compiler recognizes them as aliases for canonical keywords. This table lists every alias the lexer folds onto a canonical keyword; a keyword with only one spelling is not repeated here (it is reserved too, but it is not an alias of anything):
| Alias | Canonical keyword |
|---|---|
abs | absolute |
plus | add |
push | append |
arg | argument |
param | argument |
parameter | argument |
args | arguments |
parameters | arguments |
params | arguments |
bool | boolean |
named | called |
closed | close |
skip | continue |
define | create |
make | create |
days | day |
remove | delete |
fd | descriptor |
env | environment |
equal | equals |
exist | exists |
quit | exit |
terminate | exit |
no | false |
decimal | float |
real | float |
deallocate | free |
release | free |
starting | from |
fetch | get |
retrieve | get |
bigger | greater |
larger | greater |
more | greater |
hours | hour |
inside | in |
within | in |
integer | int |
fewer | less |
smaller | less |
lib | library |
array | list |
collection | list |
dictionary | map |
ms | milliseconds |
minutes | minute |
mod | modulo |
remainder | modulo |
months | month |
nil | nothing |
null | nothing |
numbers | number |
at | on |
opened | open |
perms | permissions |
display | print |
prints | print |
show | print |
grow | resize |
reallocate | resize |
shrink | resize |
give | return |
returns | return |
import | see |
include | see |
require | see |
assign | set |
store | set |
delay | sleep |
minus | subtract |
message | text |
string | text |
stopwatch | timer |
up | to |
treat | treating |
yes | true |
timestamp | unix |
unixtime | unix |
var | variable |
ver | version |
pause | wait |
years | year |
These cannot be used as variable names. The diagnostic names the spelling you wrote and notes which canonical keyword it aliases, so a number called ms is ... reports 'ms' as an alternate spelling of 'milliseconds', not the internal canonical name. say and output are not in this table: the lexer never folds them, so they are ordinary variable names (BUGS_FOUND #106) - only show, display, and prints are alternate spellings of print.
Every keyword listed in the tables above is likewise reserved as a variable name. Two that are easy to hit by accident are worth calling out: the flag-schema keyword flag (a flag called ...) and the property keyword empty (x's empty). Writing a number called flag is 1. or a number called empty is 1. is rejected with the same "reserved keyword" diagnostic. (As with any reserved word, you can still quote the name ('flag', 'empty') if you genuinely need it.)
Reserved Nouns and Properties#
Words reserved as the head of a built-in noun phrase, rather than as a statement starter, operator, type name, or connector:
| Keyword | Purpose |
|---|---|
arguments | Command-line arguments, accessed via 's (arguments's count, arguments's first, ...) — see Command-Line Arguments |
argument | Indexed argument access (the argument at <i>) and the the argument count phrase — see Dynamic Index Access |
environment | Environment variables, accessed via 's (environment's "HOME", environment's count, ...) — see Environment Variables |
variable | Optional noun in the environment variable "<NAME>" / the environment variable count |
input, standard | standard input - the process's stdin (Read from standard input into <buffer>.) |
byte | Single-byte access by position (byte <n> of <buffer>, Set byte <n> of <buffer> to <value>.) — see Buffer Byte Access |
elapsed | A running timer's elapsed duration (the '<timer>''s elapsed in seconds) — see Timer Properties |
error | The On error <action>. handler that runs after a failed operation — see Error Handling |
exists | Predicate on a named environment variable (the environment variable "<NAME>" exists) — see Checking if Variable Exists |
File, Buffer, List, and Time Properties#
Property words claimed by the 's syntax, or by their own access phrase, across buffers, files, lists, maps, numbers, and time values:
| Keyword | Purpose |
|---|---|
descriptor, modified, accessed, permissions, readable, writable, full | File properties, accessed via 's (<file>'s descriptor, <file>'s modified, ...) — see File Properties |
reading, writing, appending | File-open modes (open a file for reading/writing/appending ...) — see Opening Files |
keys, values | Map properties, each yielding a fresh list (<map>'s keys, <map>'s values) — see Maps |
absolute, sign | Number properties (<n>'s absolute, <n>'s sign) — see Number Properties |
element | List element access by position (element <n> of <list>) — see List Element Access |
bytes | Buffer size unit (<n> bytes in size) and seek target (Seek <file> to bytes <n>.) — see Buffers / Seeking |
current, hour, minute, day, month, year, unix | Current time and its properties (current time, <time>'s hour, ...) — see Time and Timers |
duration, running | Timer properties (<timer>'s duration, <timer>'s running) — see Timer Properties |
millisecond, milliseconds, seconds | Duration units (Wait <n> seconds., Sleep for <n> milliseconds.) — see Time and Timers |
Two classes of special word#
Not every word with a special meaning is reserved. Vox distinguishes:
- Reserved keywords: banned as bare names everywhere, because they would be ambiguous anywhere: statement starters, operators (
times,add), type names, connectors. - Contextual keywords: claimed only in the position where they mean something, and ordinary identifiers everywhere else:
start/begin/stop/finishfor timers,sendfor signals,waitinginwithout waiting,availableinis available, the things words, the property wordname, and the property wordcount, claimed after a possessive marker and in thethe argument count/the environment variable countphrases, soa number called count is 0.compiles whilearguments's countkeeps its meaning. The same treatment extends to the whole possessive/phrase family:capacity(also thewith capacity N/of capacity Nbuffer phrase),raw,all(also theall the numbers from/between …range),first,last,second(also theWait 1 second.unit:Set second to 1. Wait second seconds.compiles and waits one second),sizeand its synonymlength(alsowith size NandN bytes in size), andversion(theLibrary <name> version "…"andsee <lib> version "…"headers). Each is a bare variable name everywhere except its one fixed grammatical position;arguments's firstanda number called first is 0.both work in the same program.
The test for which class a word belongs in: if every position where the word means something is grammatically identifiable, it is contextual; only a word that would be ambiguous in ordinary positions is reserved.
Contextual Keywords (Things)#
Three words the things feature claims only inside their construct, and treats as ordinary identifiers everywhere else: the same treatment send/begin/stop get for timers. None of them is a reserved variable name, so a number called thing is 1. and To do. (a function named do) both compile.
| Word | Claimed in | Elsewhere |
|---|---|---|
thing | A thing called <name> has ... (a definition) | ordinary identifier |
has | the verb of a thing definition | ordinary identifier |
do | To do the <type>'s <member> (a member definition) | ordinary identifier |
A fourth, the, gains a second reading in this company: in To do the point's 'placed at' it pairs with a known identifier (the type), where a point's 'placed at' calls a maker that brings a new point into being. See the article rule.