User:Gilbert189/Babalang+

From Esolang
Jump to navigation Jump to search
This article is just a draft. See User:Gilbert189#Drafts for more info.

Babalang+ (or Babalang Plus) is an extension of Babalang, an esolang that uses Baba is You-like rules.

3D: 3D objects

BABA IS 3D // 8-bit integer 3-tuple

BABA IS FRONT AND MOVE // +Z direction
BABA IS BACK AND MOVE  // -Z direction
// Using NOT reverses the direction

// TODO: Better names
BABA IS TURN       // XY rotation
BABA IS TURN_PITCH // YZ rotation
BABA IS TURN_YAW   // XZ rotation

// The following also applies to WRITE, SHIFT, FALL, and SLEEP
BABA IS LEFT AND TEXT  // outputs X value
BABA IS UP AND TEXT    // outputs Y value
BABA IS FRONT AND TEXT // outputs Z value

Default values of IMAGEs

The first ever syntactic sugar of Babalang (plus)?

SKULL IS IMAGE
    SKULL HAS BABA AND KEKE

    BABA IS YOU AND MOVE

    SKULL IS LEVEL
        SKULL HAS ME
        // ...
    SKULL IS DONE

    KEKE IS LEVEL
        // ...
    KEKE IS DONE
SKULL IS DONE

Levelpacks

KEKE IS LEVEL
    KEKE HAS ME AND IT
    FOFO IS ME AND IT
    KEKE MAKE FOFO
KEKE IS DONE

ME IS LEVEL AND HIDE // Hidden objects cannot be imported.
    ME HAS BABA
    BABA IS TEXT
ME IS DONE

LEVEL IS BABA // Defines the levelpack name.
              // If LEVEL IS ... is present in the last parsed
              // rule, the file is considered a levelpack.
              // This statement must only be added as the last
              // rule, otherwise an error will be thrown.

Using levelpacks

LEVEL HAS BABA // Import the BABA levelpack. (NOT does nothing)
BABA MAKE KEKE // Import KEKE from the BABA levelpack. (NOT does nothing)
ME IS YOU AND MOVE
KEKE HAS ME AND ME
KEKE IS POWER AND TEXT // prints ASCII 0x02

Searching for levelpacks

Upon executing, the interpreter will search for all files with the extensions .babaplus or .bbp or all sub-directories on the main directory. Files take priority over directories. Caching may be done to ease future executions.

Files

The file name doesn't matter when it's being imported (although a warning is given if it doesn't correspond with the levelpack name).

Directory

All directory levelpacks must have a LEVEL.babaplus (or LEVEL.bbp) file on them (case insensitive). All objects (except hidden ones) defined in that file are available to import. The directory name will be the name of the levelpack.

Invalid levelpack names or levelpacks without the LEVEL file will not be considered (a warning may be given if found).

Sibling imports

Currently sibling imports aren't defined yet. For now, you could emulate them by creating a symlink to your sibling levelpack (this method is not normative).

Standard levelpacks

This section is incomplete. It also need to be split into their separate pages.

Keywords

For the following levelpack definitions, these keywords may be used.

destroy
To destroy an object means to remove all bindings present to the object. This only has significance with IMAGE instances, where some of them have special behavior when destroyed. Usually you can do so by setting a variable binding them to another value, preferably EMPTY (though when an object is still bound to something else, e.g. some random GROUP or IMAGE instance that's hasn't been destroyed, it's not considered destroyed).
When the code is finished, all objects will be destroyed.
integer
An integer is a YOU object, specifically one that's FACING RIGHT, and has a value stored in its X position. Its Y position must be 0.
This term is only for YOU objects that's only intended to store a single value. For uses other than that (and if the direction of the object matters), it should still be referred to as a YOU object.
string
A string is a GROUP of YOU objects. Each YOU object corresponds to a single character, with the axis of the YOU's direction selecting the character value from their coordinates. They are ordered in their stack order; the first YOU object pushed will be the first character. When creating strings, all YOU objects must be FACING RIGHT. Unless specified, reading a string will consume it, emptying out the GROUP.


COMPUTER: Operating system interface

ENV IS IMAGE

A special IMAGE which contains the process environment variables.

When the currently FOLLOWed attribute is EATen, this will automatically modify the environment variable (the contents are not consumed). Similarly, MAKEing it will query the environment variable and assigns a string to the variable in statement.

Note that ENV may only EAT strings. If given something else, an error will be thrown.


SHELL IS LEVEL AND HAS ARGS

A LEVEL object that executes a shell command. ARGS should be a string.

Returns an integer with the exit code of the command.


TAPE IS IMAGE AND HAS NAME AND MODE
FILE MIMIC TAPE

An IMAGE object that can read, write, and modify files. NAME should be a string, and MODE should either be a YOU or YOU2 object. Depending on the MODE argument, the file would be:

  • opened for reading if it's FACING UP;
  • opened for writing if it's FACING DOWN; or
  • opened for appending if it's FACING RIGHT

This IMAGE defines the following attributes:

  • MOTOR, which controls the file pointer. MOTOR MAKEs a YOU2 object that returns the position of the file pointer (wrapping around).
    When MOTOR EATs a YOU or YOU2 object, the file pointer is:
    • decremented by their X position if it's FACING LEFT;
    • incremented by their X position if it's FACING RIGHT;
    • set to their X position forward from the starting position if it's FACING UP; and
    • set to their X position back from the end position if it's FACING DOWN.
  • CURSOR, which reads and writes a unit to/from the file. When CURSOR EATs a unit, it is written to the file. CURSOR MAKEs a unit, reading it from the file. Doing either of those will advance the file pointer.
    What constitutes a unit is dependent by the MODE argument.
    • If its Y position is 0, the unit would use the X position to store the value.
    • Else if its X position is 0, the unit would use the Y position to store the value.
    • If none of its axis components are 0, the unit would use both the X and Y position to store the value, largest component first.
    • The object type of the unit is equal to the MODE argument.

The file would be closed if its instance is destroyed.


SYSTEM IS IMAGE

An IMAGE containing attributes to identify the current operating system. The following attributes are defined:

  • NAME: a string of the operating system name
  • VERSION: a string of the operating system version
  • HARDWARE: a string of the hardware name
  • DEVICE: a string of the device name (e.g., your computer's host name)

4D: 4D objects

LEVEL HAS 4D

BABA IS 4D // 8-bit integer 4-tuple
BABA IS ANA AND MOVE  // +W direction
BABA IS KATA AND MOVE // -W direction
// Using NOT reverses the direction

// TODO: Better names
BABA IS TURN       // XY rotation
BABA IS TURN_PITCH // YZ rotation
BABA IS TURN_YAW   // XZ rotation
BABA IS TURN_WHEEL // XW rotation
BABA IS TURN_HEAVE // YW rotation
BABA IS TURN_CHASE // ZW rotation
// Using Greek names
BABA IS TURN_CYLIND // XW rotation
BABA IS TURN_VOLLEY // YW rotation
BABA IS TURN_CUNIGO // ZW rotation

// The following also applies to WRITE, SHIFT, FALL, and SLEEP
BABA IS LEFT AND TEXT  // outputs X value
BABA IS UP AND TEXT    // outputs Y value
BABA IS FRONT AND TEXT // outputs Z value
BABA IS ANA AND TEXT   // outputs W value

META: Custom word definitions

LEVEL HAS META
META MAKE METHOD

STRAFE_LEFT IS LEVEL
	STRAFE_LEFT HAS OBJECT
	OBJECT IS NOT TURN
	OBJECT IS MOVE
	OBJECT IS TURN
STRAFE_LEFT IS DONE
METHOD HAS STRAFE_LEFT AND IS POWER

BABA IS YOU
BABA IS STRAFE_LEFT