Ixux

From Esolang
Jump to navigation Jump to search

Ixux is an object-oriented esolang by User:BoundedBeans inspired by Unix/Linux commands.

Basic concepts

  • A string is an arbitrary-length sequence of bytes. This may include null bytes, though they have limited support with commands.
  • A file path usually means a real file, which may use Windows or Unix paths depending on the system. However, regardless of system, paths starting with /usr/../ refer to local variables, paths of the format /bin/../[uppercase hex string or +]/[string without slash]/f refer to a field access of an object (the hex string, or + for the current object) with field name (the other string). The path /bin/../G is for the return value of a method, settable within that method. Paths following the format /bin/../G/[path] refer to global variables. Paths named /bin/../H[DecimalNumber] refer to zero-based parameters to a method. The path /bin/../I contains the number of parameters represented as a decimal string. Some special variables have paths as files in the directory /bin/../Ixux/. Extension special variables can use /bin/../IxuxE/
  • Variables can be strings or objects. Objects are maps from slashless null-less strings to strings or further objects. /dev/stdin, /dev/stdout, and /dev/stderr automatically jump past the device files and directly print/input it, which means it won't require root permissions.
  • Variables that don't exist are equivalent to existing variables set to the empty string.
  • Strings, including the above mentioned file paths, are always written in code as their uppercase hexadecimal representation enclosed in square brackets. Assume ANSI unless otherwise specified.
  • The method @Init@ of class @StartClass@ will run first, passed the command line arguments.

Syntax

Ixux has significant whitespace, where each level should be exactly four spaces indented from the last.

A class is written like:

?CLASS? @ClassName@
    ?METHOD? @MethodName@
        *code*
    ?METHOD? @AnotherMethod@
        *code*

A class must have a method named @Init@ that creates the object based on the parameters.

A special syntax exists for a line that activates on any line containing exactly three exclamation points.

Ignored!number of preceding spaces!line contents!ignored

For example:

A comment!8!{ECHO} [486921] => [2F7573722F2E2E2F610A]!Another comment

Equality semantics

  • Strings are considered equal if they are the same length and encode an identical sequence of bytes.
  • Two objects are equal if both have a method named @Equal@ which returns the string "1" when called with the other as the only parameter.
  • An object is equal to a string if the object has a method called @EqualString@ which returns the string "1" when called with the string as the only parameter.

Special variables

  • /bin/../Ixux/Commands is an @Ixux_Dict@ with @Ixux_Function@ values, which can be used for custom commands of the format {[name]} [parameter]*. The default commands aren't included in here, and neither is anything else at the start, but you can both add new commands and override old ones using this. The function will receive an @Ixux_Dict@ of all the local variables of the caller as its 0th argument, which can be modified to change the values. The remaining arguments will be passed from index 1 and onward.

Special classes and methods

Special classes and methods have names starting with Ixux_ or IxuxE_, which are reserved. Ixux_ is for official functionality while IxuxE_ is for extensions.

List of special classes

  • @Ixux_Class@
    • Constructor has two forms:
      • If the first parameter is [00], the second parameter is used as the name of an already existing class to manipulate
      • If the first parameter is [01], the second parameter is used as a string of Ixux code representing the class. When constructed, this will create a new class at runtime.
    • Method @WriteMethod@
      • Takes a string representing a method declaration with one indentation level removed, creates or overwrites the method in this class. If this method is the current method, continue running the method as if it hadn't been modified, but it will take effect on any other calls, including if the method recurses.
    • Method @DeleteMethod@
      • Takes a string representing the method name (without @), and deletes it from the class.
    • Method @Extend@
      • Takes another Ixux_Class as an argument, makes the current class extend the argument and inherit all non-overridden methods. Later calls to this create multiple inheritance, with later calls taking priority over earlier ones.
    • Method @Collect@
      • Removes the class from the class list to be garbage-collected.
  • @Ixux_Function@
    • Constructor takes a string containing an Ixux code block with two removed levels of indentation.
    • Method @Call@
      • Calls the function with the parameters given. The current object is set to the function itself.
  • @Ixux_Dict@
    • Constructor takes no arguments.
    • Method @Set@
      • Takes a string and an object, sets the entry in the dictionary.
    • Method @Get@
      • Takes a string, gets the entry and returns the object it was set to, or the empty string if not set to a value. Sets /bin/../G/Ret0 to [30] if the dictionary does not contain the key, otherwise sets it to [31] and sets /bin/../G/Ret1 to the value.
    • Method @Remove@
      • Takes a string, removes the entry with that ket


Commands

The only statement is the assignment statement, written as:

(Command) => (file path as hex string)
: @[MethodName]@ [ObjectPath] [ParameterPath]* Calls a method on the object with parameters.
. @[ClassName]@ [ParameterPath]* Constructs an object with the @Init@ method.
{ECHO} [Argument]* Returns the arguments, separated by byte 32, followed by byte 10. If one of the arguments is "-n", it is ignored and byte 10 is not added to the end.
{CAT} [Argument]* Linux cat with support for -AbeEnstTuv. Does not support long options. Returns the output.
{CUT} [Argument]* Linux cut with support for -bcfds and --output-delimiter=string. Returns the output.
{PASTE} [Argument]* Linux paste with support for -d. Returns the output.
{XXD} [Argument]* Linux xxd with support for -abcEglprsu. Long options not supported. Returns output.
{HEAD} [Argument]* Linux head with support for -cn and negative numbers for the values of those options.
{RM} [Argument]* Linux rm with support for -rf. Long options and -R not supported. Returns output.
^[FilePathHex] Evaluates the contents of the file or variable as a line of code.
| [CommandInNestableAngleBrackets]+ Makes a chain of piping outputs to inputs. Returns output of the final command.
% [FilePath1] [FilePath2] ~[LabelName]~ If the two variables are equal, goto the command after the ~~ command with the same label name and return the empty string. Otherwise, just return the empty string.
~[LabelName]~ Label placeholder, when encountered (such as by advancing from the previous command), return the empty string.

Examples

Hello, world!

?CLASS? @StartClass@
    ?METHOD? @Init@
        {ECHO} [48656C6C6F2C20776F726C6421] => [2F6465762F7374646F7574]

Truth-machine

?CLASS? @StartClass@
    ?METHOD? @Init@
        {HEAD} [2D63] [31] [2F6465762F737464696E] => [2F7573722F2E2E2F7472757468]
        {ECHO} [2D6E] [30] => [2F7573722F2E2E2F31]
        % [2F7573722F2E2E2F7472757468] [2F7573722F2E2E2F31] ~Zero~ => [2F7573722F2E2E2F6A756E6B]
        ~Loop~ => [2F7573722F2E2E2F6A756E6B]
        {ECHO} [2D6E] [31] => [2F6465762F7374646F7574]
        % [2F7573722F2E2E2F31] [2F7573722F2E2E2F31] ~Loop~ => [2F7573722F2E2E2F6A756E6B]
        ~Zero~ => [2F7573722F2E2E2F6A756E6B]
        {ECHO} [2D6E] [30] => [2F6465762F7374646F7574]