X.so

From Esolang
Jump to navigation Jump to search

X.so is a stack-based, esoteric programming language created by User:AnotherTest. The X in the name comes from extensible, and the so extension refers the to the shared object files that the X.so interpreter may dynamically load as a form of plugins.

Syntax

The language has a rather minimal syntax which can be described by the following BNF definition (terminals are marked in bold):

call    := id | id . call
literal := int | real | string | char | call
stmnt   := literal stmnt | ε
body    := block body | stmnt
block   := $ id ( body )
program := block EOF

Whitespace (consisting of tabs, newlines and spaces) is ignored.

Semantics

Integer, real, string and char literals are pushed on the stack when they are encountered. When a call instruction is encountered, the execution continues in the body of the called routine.

There are only 2 build in routines: Include and Exclude. Import loads the shared object files dynamically with as the name the the top-most stack item. This item should be a string. For example, "X" Import will load ./libX.so. This allows calling routines called X.*. Exclude unloads so files. At the end of execution, all included plugins are automagically excluded.

The execution begins in the "Main" routine. This routine must be in the root routine, which is often given the name of the program. This entry point may also be an indirect child of the root routine.

Standard plugin: XCore

The XCore plugin (generally stored as libX.so on the filesystem) contains the language core functionality. It includes various important features, such as: Pop, If, Add, Subt, Mult, Div, Show, etc. To allow if-statements, the XCore plugin contains the X.so interpreter. Because of this, XCore supports reflection.

Completing the language: HELP

The HELP is used to complete the language: it adds comments and allows a function-call like notation for calls. The x.help file contains the following directives:

# \!([a-zA-Z_][a-zA-Z0-9_]*\s*(\.\s*[a-zA-Z_][a-zA-Z0-9_]*)*)\(([^\)]*)\) := \3\s\1
# \/\*.*?\*\/ := \s
# //.*?\n :=

Computation class

The computational class of X.so depends highly on the plugins included. XCore currently does not provide a Turing complete system.

Examples

Hello, world!

/**
 * Hello world in X.so.
 */
$HelloWorld (
    $Main(
        !Include("X")
        !X.Show("Hello, world!\n")
    )
)

After preprocessing by HELP:

$HelloWorld (
    $Main(
        "X" Include
        "Hello, world!\n" X.Show
    )
)

Cat

$Cat (
    $Main (
        !Include("X")
        !X.Show(X.Ask)
    )
)

After preprocessing by HELP:

$Cat (
    $Main (
        "X" Include
        X.Ask X.Show
    )
)

External resources