Grawlix
Jump to navigation
Jump to search
This is the horrible Grawlix Programming Language - created by User:DMC with the intent of introducing enhancements to brainfuck that still uphold it's spirit.
grawlix – Cartoonist's term for random symbols and punctuation used to represent swearing.
Description
- 8 bit memory cells (or other bit amounts)
- Everything initialized to zero
- Cell values rollover
- Program memory infinite
- Data memory infinite
- Stack memory infinite
- T - top of stack
- P - data pointer
- (P) - byte value at P
- P < 0 is an error and should halt the program
- Pop when T = 0 is an error and should halt the program
- A program with only > < + - , . [ ] is Brainfuck, not Grawlix
- The Grawlix interpreter can be used as a Brainfuck interpreter
- Turing complete: yes, because Brainfuck is Turing complete
Enhancements to brainfuck
- Stack operations
- Decimal I/O
- Another loop structure
- Multiply / divide by two
- Functions
Functions
- Function definition '{ code }' can be anywhere in the program listing
- Function definition in program listing '{' is skipped to command after matching '}'
- Only function call '@' runs function code
- To call a function: push function number onto stack, call function with '@'
- The function number is determined by program parsing in the order it is encountered, starting with zero
- 256 functions allowed
Program parsing
- Bracket integrity check
- Parenthesis integrity check
- Brace integrity check
- Tabulate open/close brackets
- Tabulate open/close parenthesis
- Tabulate function locations
Brainfuck commands
><+-,.[]
Grawlix Commands
Command | Description |
---|---|
: |
Push (P) |
; |
Pop (P) |
? |
(P) = input decimal number mod 256 |
( |
Proceed to next command after ‘(‘ if (P) == 0, the opposite of brainfuck |
) |
Return to matching '(' |
{ |
Begin function definition |
} |
End function definition |
@ |
Function call: function number previously pushed onto the stack, performs a pop operation |
/ |
Shift (P) right: zero > 7 > 6 > 5 > 4 > 3 > 2 > 1 > 0 > null |
| |
Shift (P) left: null < 7 < 6 < 5 < 4 < 3 < 2 < 1 < 0 < zero |
= |
Print out (P) as a zero-filled three digit decimal number |
^ |
Halt |
Some possible code constructs
Code schematic | Explanation |
---|---|
some code | |
a function definition | |
a function call inside a function definition | |
two function definitions | |
possible but unnecessary function definitions | |
+:@ push 1,call function 1
| |
loops | |
a possible loop structure, not a syntax error, unknown if it can be made to do something useful |
Examples
Hello World!\n
+|||+|||.>+++|||+||+.+++++++..+++.>+||| ||.>+|||+++|||-.<<.+++.------.--------. >+.>>+||+|.
Fibonacci
correct until an 8-bit rollover occurs
>>+||+|<+<=>[>.<=:<[>+<-];>]!
Truth-machine
:+:?(;;=^);[=]
External resources
- Grawlix Programming Language – Interpreter written in Python 3