Masqualia

From Esolang
Jump to navigation Jump to search

Masqualia is designed by PSTF.

Language Overview

Masqualia is based on Brainfuck, is extended version of Brainfuck. Masqualia supports conditional jumps, loops, arithmetics, I/O, has a tape, a stack, four accumulators, and can access the register.

Masqualia didn't uses traditional Brainfuck syntax, but Assembled syntax instead.

Basic commands

FWD
BKD
INC x
DEC x
WRT x
REA x
LOOP cond
END
  1. FWD moves pointer forward.
  2. BKD moves pointer backward.
  3. INC x increases x by 1. CURCELL is pointed cell, STACKTOP is stack top, AX BX CX DX AL BL CL DL AH BH CH DH CS IP DS DP SS SP RG01 RG02 RG03 are registers, STACK2ND is second stack top element.
  4. DEC x same as INC x, but decrease instead of increase.
  5. WRT x outputs x as character.
  6. REA x reads a character and push it into x.
  7. LOOP is [, and END is ][1]. You can modify the condition by yourself, if blank it then the condition is CURCELL!=0.

Slightly advanced commands

OUT x
IN x
SAY x
LSN x
ADD x y
SUB x y
MUL x y
DIV x y
MOD x y
EXP x y
DCL x type val
SET x (type) (val)
OR x y
AND x y
XOR x y
NOT x
REV x
  1. OUT x outputs the value of x.
  2. IN x inputs a string to x. If x is CURCELL, then parse out the integer in decimal. If x is STACKTOP, then push the string reversely.
  3. SAY x output x as integer.
  4. LSN x inputs an integer and push it into x.
  5. ADD x y adds y to x.
  6. SUB x y subtracts y from x.
  7. MUL x y multiplies x by y.
  8. DIV x y divides x by y. If y is zero then raises "Divide by zero".
  9. MOD x y modulos x by y. If y is zero then raises "Divide by zero".
  10. EXP x y multiplies x by x over and over y times. If y is zero then return 1.
  11. DCL x type val declares a variable x with specified type and value.
  12. SET x type val assigns specified type or value to x.
  13. OR x y bitwise ors x by y.
  14. AND x y bitwise ands x by y.
  15. XOR x y bitwise xors x by y.
  16. NOT x bitwise nots x.
  17. REV x reverses x. If x is list or string then it is flipping, if x is boolean then it is logical not, and if x is integer or float then it is negation.

Advanced Commands

LOG x y
HXD
DCM
OCT
BIN
TER
BSF
NOP
PAUSE
EXT
BRK
CTN
BYE
  1. LOG x y Gets the y-base logarithmic number of x.
  2. HXD turns the I/O to hexadecimal.
  3. DCM turns the I/O to decimal.
  4. OCT turns the I/O to octal.
  5. BIN turns the I/O to binary.
  6. TER turns the I/O to ternary.
  7. BSF turns the I/O to base-64.
  8. NOP is a no operation.
  9. PAUSE pauses and print "Press any key to continue..." and then wait the user input.
  10. EXT exits the program.
  11. BRK breaks a loop.
  12. CTN breaks the current round of loop.
  13. BYE exits the programming environment.

More Advanced Commands

#INCLUDE library_name
DO function_name param_list code END
RUN function_name param_list END
OPEN x y
CLOSE x
READFRM x
WRITETO x
PUSH x
POP x
DUMP x y
SWAP x y
SORT list
RST x
WAIT x
  1. #INCLUDE library_name includes the library you specified.
  2. DO function_name param_list code END defines a function.
  3. RUN function_name param_list END runs a function.
  4. OPEN x y opens the file x, with the 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.
  5. CLOSE x closes the file x.
  6. READFRM x directs input to x. If x is CON, then the input is directed to stdin.
  7. WRITETO x directs output to x. If x is CON, then the output is directed to stdout.
  8. PUSH x pushes x into the stack. If x is not specified, then duplicate the stack top.
  9. POP x pops the stack top and store it in x. If x is not specified, then discard the stack top.
  10. DUMP x y dumps x to y. y can only be registers, pointed cell, or stack top.
  11. SWAP x y swaps the value between x and y.
  12. SORT list sorts the list.
  13. RST x resets x to initial value.
  14. WAIT x waits for x milliseconds.

Super Advanced Commands

RAND
RANDINT a b
RANDFLT a b
CHOICE list
SHUFFLE list
SRCH list x
LAMBDA foo param_list code END
CALL foo param_list END
  1. RAND generates a random float number between 0 and 1.
  2. RANDINT a b generates a random integer between a and b.
  3. RANDFLT a b generates a random float number between a and b.
  4. CHOICE list randomly chooses an item from the list.
  5. SHUFFLE list randomly shuffles the list.
  6. SRCH list x searches x from list. Return TRUE if x is found, otherwise FALSE.
  7. LAMBDA foo param_list code END is a lambda expression.
  8. CALL foo param_list END calls a lambda expression.

The Very, Extremely, Devastatingly, Whoppingly, Unsurprisingly, Obviously, Absolutely, Universal, Godlike, and ONLY TWO Advanced Commands

EVAL x
EXEC x
  1. EVAL x evaluates x and return the result.
  2. EXEC x executes x as Masqualia code and return nothing.

Example

Hello, world!

OUT "Hello, world!"

A+B Problem

IN CURCELL
FWD
IN CURCELL
LOOP
SUB CURCELL 1
BKD
ADD CURCELL 1
FWD
END
BKD
SAY CURCELL

Note

  1. ADD x y <-> x + y
  2. SUB x y <-> x - y
  3. MUL x y <-> x * y
  4. DIV x y <-> x / y
  5. MOD x y <-> x % y
  6. OR x y <-> x | y
  7. AND x y <-> x & y
  8. XOR x y <-> x ^ y
  9. EXP x y <-> x ** y
  10. NOT x <-> ~x
  11. LAND x y <-> x && y
  12. LOR x y <-> x || y
  13. LNOT x <-> !x

(All operation symbols are from Python.)

Categories and References

  1. END can also used as function end, or subroutine end.