IMPRAL

IMPRAL is a command parsing and evaluation library for a LISP dialect, intended for reasonably ergonomic and specialized commandline input within larger applications and frameworks.

DISCLAIMER: Currently incomplete/still in development. Do not use.

Introduction

Features

A very quick overview:

Syntax & Semantics

Literals

A literal is a simple value, like a number, string, boolean, etc. etc.

Following is a list of possible literals:

References

There are several types of reference:

Command Syntax

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:

  1. The symbol identifying the command.
    A unique bareword or any of the built-in operators. Neither positional nor named arguments may be placed before the command identifier.

  2. The positional arguments.
    A whitespace separated list of values.

  3. 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. One may also write flag-arguments, consisting of a + or - and a bareword as name.

  4. Continuation command. (optional)
    Another command that is an extra positional parameter in the last position, written after a :.

  5. Command Delimiter. (optional)
    If the parser encounters a ;, it will stop parsing, regardless of what comes after the semicolon.

To sum this up:

Subcommands

Commands can be enclosed in parentheses and be used as arguments for other commands: (symbol …)

Logical Operators

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 …

Both of the logical operators may be chained; evaluation will occur from left to right.

Command Pipes

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.

Indexing

By using the ./.?-syntax, members of values may be accessed.

Ranges

By typing two consecutive dots (..), a range between/of two expressions can be created.

Exists?

By using the ? postfix-operator, one can test if the given value is null.

Relation

TODO: Specifiy how the relation/relative-to operator should work.

TODO