view src/ploki/doc/ploki-syn.txt @ 12292:d51f2100210c draft

<kspalaiologos> `` cat <<<"asmbf && bfi output.b" > /hackenv/ibin/asmbf
author HackEso <hackeso@esolangs.org>
date Thu, 02 Jan 2020 15:38:21 +0000
parents ac0403686959
children
line wrap: on
line source

                      === THE PLOKI LANGUAGE: SYNTAX ===


GENERAL STRUCTURE:

A ploki program consists of a (possibly empty) sequence of ordinary lines or
include directives.

An include directive is either absolute or relative. An absolute include
directive is optional whitespace, followed by "INSERT DA", followed by one
or more non-whitespace characters, followed by "HERE", followed by optional
whitespace. A relative include directive is optional whitespace, followed by
"INSERT", followed by optional whitespace, followed by one or more
non-whitespace characters, followed by "HERE", followed by optional
whitespace.

An ordinary line consists of optional whitespace, a label, and stuff.

Stuff consists of an instruction and the rest of the line. Any "??/\n"
sequence (that's four characters: ?, ?, / and newline) in stuff is ignored
unless the instruction is REM.
Example:
WUNT "foo??/
bar"
is equivalent to
WUNT "foobar"
.

There are two types of labels, static and dynamic.
 * A static label consists of the three letters "FOR", whitespace and a
   non-empty sequence of non-whitespace characters which hasn't been defined
   as a static label yet, followed by optional whitespace.
 * A dynamic label consists of a possibly empty sequence of digits, followed
   by optional whitespace.


INSTRUCTIONS:

These are the available instructions (in no particular order):

  * "#!":
    A comment. The rest of the line is ignored.

  * "REM":
    A comment. The rest of the line is ignored but scanned for "REM" ...
    "\n" pairs. In other words, REM comments may nest.

  * "LET", "LEET":
    Assignment. The rest of the line is an optional lvalue, followed by an
    expression.
  
  * "WUNT", "SET":
    Output. The rest of the line is an optional value, followed by an
    expression.

  * "IF":
    Conditional jump. The rest of the line starts with an expression.

  * "ELSE":
    Jump. The rest of the line is ignored.

  * "FI", "END IF":
    Jump target. The rest of the line is ignored.

  * "#":
    System call. The rest of the line starts with an expression.

  * "GOTO", "GOFOR":
    Computed jump. The rest of the line starts with an expression.

  * "NEXT":
    Static jump. The rest of the line must start with the name of a static
    label.

  * "ANRUF":
    Computed call. The rest of the line starts with an expression.

  * "ABRUF":
    Computed call. The rest of the line is a value, followed by an
    expression.

  * "END":
    Exit. The rest of the line starts with an expression.

  * "KTHX":
    Return. The rest of the line starts with an expression.

  * "CLAUDS":
    Close. The rest of the line starts with an expression.

  * "FLUSH":
    Flush. The rest of the line starts with an expression.

  * "RESET":
    Clear error/eof flags. The rest of the line starts with an expression.

  * "IACS":
    Throw. The rest of the line starts with an expression.

  * Anything else:
    Output. The rest of the line starts with an expression.


EXPRESSION SYNTAX:

An expression either an expression followed by a binary operator and a
value, or a value. A value is either an lvalue or an rvalue. An lvalue is a
plain variable or a hash variable. An rvalue is a special symbol, a
constructor, a unary operator followed by a value, a binary operator
followed by a value, or a "(", followed by an expression, optionally
followed by ")". A plain variable is an identifier; a hash variable is an
identifier, immediately followed by "(", an expression and an optional ")".
An identifier is a non-empty sequence of "a" .. "z", "A" .. "Z", "$".

Special symbols: \<DIGITS> (where <DIGITS> is a non-empty sequence of
digits), \!, \?, \_, \@, \ARG, \AUSG, \EING, \E, \FEHL, \PI, \,  (the empty
string).

A constructor is
- a floating point number as recognized by strtod() -OR-
- a string starting with '"', followed by a 0 or more of the following: 
  "\V" followed by a value, or "\" followed by a non-newline character, or a
  non-'"' character;
  optionally terminated by '"' -OR-
- a list starting with "#<", followed by 0 or more values, optionally
  terminated by "#>".

Unary operators: \ARG:, \ENV, \L, \Q, \R, \U, @-, @+, @ABS, @ACOS, @APERS,
@ASIN, @ATAN, @ATAN2, @CHR, @COS, @DEF-P, @EDD-P, @ENV, @ERR-P, @EVAL, @GET,
@INT, @IO-P, @LAPERS, @LEGS, @LENGTH, @LG, @LN, @NEG, @NOT, @NUM, @ORD,
@OMFG, @REMOVE, @RENAEM, @REVERSE, @SAG, @SAPERS, @SIN, @SQRT, @STR, @SUCH,
@TAN, @TYPE OF, @<LABEL> (where <LABEL> is the name of a static label), @.

Binary operators (separated by spaces):
+ - * / % ^ _ < [ { > ] } = ! : ; & | ~ ` ' . , ?o~

# vi: set tw=76 et: