IMPRAL is a command parsing and evaluation library for a LISP dialect, intended for reasonably ergonomic and specialized commandline input.
DISCLAIMER: Currently incomplete/still in development. Do not use.
A very quick overview:
Null
0b…
, 0o…
, 0d…
, 0x…
[ 1, 2, 3 ]
, commas optional){ a=1, b=2, c=3 }
, commas optional)0x[C0 +FF -EE]
)$my-ref
@my-ref
$
$$
|
… |? bar | …
(…)
)foo.bar
)A literal is a simple value, like a number, string, boolean, etc. etc.
Following is a list of possible literals:
null
.true
and false
. That's it.1337
-1
42.69
1.0e-5
0b101010
0xC0FFEE
_
and -
, always starting with at least one letter."Hello, World!"
[item1, item2, … itemN]
(the commas are optional!)list item1 item2 … itemN
{ key1: val1, key2: val2, …, keyN: valN}
> There must be one or more ,
between the key-value pairs;
> there may be a ,
before the }
.mmap key1 val1 key2 val2 … keyN valN
There are several types of reference:
@NAME
.$NAME
or $NUMBER
.$
.$$
.The language, like any Lisp does, consists of commands (function calls) stored as lists, where the first item in the list is a symbol, representing the name of the specific command to be evaluated followed by any number of positional arguments. Where things deviate is that IMPRAL supports named parameters, written after the positional arguments, for sake of convenience.
So, a command consists of three (and a half) parts:
The symbol identifying the command.
A unique bareword or any of the built-in operators.
Neither positional nor named arguments must come before the command identifier.
The positional arguments.
A whitespace separated list of values.
The named arguments.
A whitespace separated list of key=value
-pairs; the keys are always barewords.
Named arguments are required to be written after the positional arguments.
The only exception to this are continuation commands in the last position.
Continuation command. (optional)
Another command that is an extra positional parameter in the last position, written after a :
.
To sum this up:
symbol arg1 arg2 … argN
symbol … kvarg1=val kvarg2=val … kvargN=val
symbol … …: command
Commands can be enclosed in parentheses and be used as arguments for other commands: (symbol …)
By writing two commands separated by &&
, the latter command will only be executed if the former succeeds, with the result being bound to $
: foo … && bar $ …
By separating them with ||
instead, the latter command will only be executed if the former fails: foo … || bar …
A sequence of commands can be written as a pipe
, in which every command passes it's result ($
) to the next command: players | where $$.health less 50 | heal $
If a command returns an iterator, the iterator's items will be passed thru the pipe, instead of the iterator itself.
By using the .
/.?
-syntax, members of values may be accessed.
By typing two consecutive dots (..
), a range between/of two expressions can be created.
By using the ?
postfix-operator, one can test if the given value is null
.
TODO: Specifiy how the relation/relative-to operator should work.