Apollo (PSTF)

From Esolang
Jump to navigation Jump to search

Apollo is a Brainfuck derivative designed by PSTF.

This is inspired from Artemis, Brainfuck 2.0, Masqualia, BFInfinity, Javascript, and Brainfuck extended.

Syntax Overview

As a Brainfuck derivative, Apollo is Turing-complete, has a tape with length 1000000(or infinity), an accumulator, some registers, and a stack.

Command list

Most basic commands

FORWD x: Move pointer forward x cell. Leave blank means 1.
BCKWD x: Same as FORWD -x.
INCRS x: Increase x by 1. 
         CELL means pointed cell, STTOP is stack top,
         ST2ND is second-to-top element of stack, ACC is accumulator,
         AX BX CX DX AL BL CL DL AH BH CH DH IP RG01 RG02 RG03 are registers.
         Change on IP will jump forward x instructions.
DECRS x: Same as INCRS -x.
WRITE x: Output x as ASCII character.
READS x: Input an ASCII character and store its value in x.
WHILE x: If x is true, do the following code block forever.
BEGIN: Marks a start of a code block.
END: Marks an end of a code block.
;: Seperates two commands.

Slightly advanced commands

PUSH x: Push x into the stack.
POP x: Pop stack top from the stack and store into x.
OUTPUT x: Output x's value directly.
INPUT x: Inputs a string to x. If x is CELL, then parse out the integer in decimal.
         If x is STTOP, then push the string reversely.
SPEAK x: Output x as an integer.
LSTEN x: Input an integer and store it into x.
ASSGN x y: Assign y to x.
DECLR x y z: Define a variable calls x, with type y and value z. Z can be omitted.
INVRT x: Reverse the value of x.
All operation sign are from python.
BASE x: Change the I/O to base-x.
NOP: No operation.
BREAK: Break a loop.
EXIT: Exit the program.
HALT: Halt the program until any keystroke.
GOODBYE: Exit the programming environment.
CONTINUE: Skip this round of loop.

Advanced commands

#INCLUDE library_name: Include the specified library.
DO function_name param_list code END: Define a function.
RUN function_name param_list END: Run a function.
OPEN x y: Open the file x with operation y.
          "r" is read-only, "r+" is read-write, "w" is write-only, "a" is append, "a+" is read-append. 
          If the operation y is read-only and x doesn't exist then raise "No such file or directory", 
          otherwise if y is others and x doesn't exist then generates the file x.
CLOSE x: Close the file x.
READFRM x: Redirect input to x. CON means stdin.
WRITETO x: Redirect output to x. CON means stdout.
SWAP x y: Swap the value of x and y.
SORT list: Sort a list immediately.
RESET x: Reset x to initial value.
WAIT x: Halt for x milliseconds.

Advanced commands 2.0

RAND: Generate a random real number in [0, 1].
RANDINT a b: Generate a random integer in [a, b].
RANDFLT a b: Generate a random real number in [a, b].
CHOICE list: Choose a random element from list.
SHUFFLE list: Shuffle the list randomly.
SERCH list x: Searches x from list. Return TRUE if x is found, otherwise FALSE.
LAMBDA foo param_list code END: Lambda expression.
CALL foo param_list END: Call lambda expression.

Advanced commands 3.0

#MACRO x y: Macro-define x as y.
#UNDEF x: Withdraw the definition of x.
FLOOR x: Round x towards 0.
CEIL x: Round x away from 0.
ROUND x: Round x as usual.
ABS x: Return |x|.

Symbol form

Well, this currently have no symbol form, but we'll make it in future.

Example

Currently we have no example either. We'll make it in future.

Categories and References