From Esolang
Jump to: navigation, search

PHAWN is a grid-based esoteric language. It uses a pointer to the current instruction, which bounces between the edges of the grid. Certain instructions will have the opposite meaning if executed when the instruction pointer is moving in a different direction. PHAWN is still on the drawing board.

Language Overview

PHAWN uses a stack to hold its data. The program begins at the entry point and the instruction pointer moves right by default. There is no instruction to change the direction of the pointer, it only changes when the end of the line is reached. The instruction at the end of a line is not executed twice. When the pointer comes accross an integer the register is set to that value. For integers which are longer than 1 digit (and therefore conflict with the consistency grid) the pointer considers the digit on the far left to be the position on the grid.

$ Entry Point
# Exit Point
> Push the value in the register (Pop if moving right)
< Pop the value on the top of the stack and places the value on the register (Push if moving left)
} Input (Output if moving left)
{ Output (Input if moving left)
/ Skip (If the pointer is moving right)
\ Skip (If the pointer is moving left)
^ Jump up to the next line
_ Drop to the line below
~ Jumps if the top number is greater than the second top, otherwise it drops. (The stack is unchanged.)
+ Pop the top two values, add them and push the result
- Pop the top two values, subtract the first from the second and push the result
* Pop the top two values, multiply them and push the result
? Pop the top two values, divide the second by the first and push the result. A divide by zero is an error and no numbers are pushed but the top two values still popped.
& Toggles output between Character and Integer. (Integer by default)
% Pops the top two numbers and pushes them in reverse order. (Swaps the top two values)
, Comment
. Do nothing


The following a simple program in PHAWN which takes user input and immediately prints it out.


Here is the famous "Hello World" program.

_                 <
 _ $33>100>_   114^
_.          /^/<111>\87\>\32\>
, Output: Hello World!

Characters are pushed in the ASCII decimal form and printed out as characters.

This example prints Fibonacci numbers until they are greater than 100000000

<<>>{^    _

External resources

Python PHAWN Interpreter

Quine Written by Keymaker