We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Phi

From Esolang
Jump to navigation Jump to search

Phi, or Φ, is an Esolang designed by PSTF.

It is a Brainfuck derivative.

Data storage

The program memory is composed of a theoretically infinite number of cells, that each store a single integer datum, in the range of Z.

At any instant in the program, a pointer marks the activated cell. The memory is normally infinite long(or expandable), but 1,000,000 cells when Restricted or Folded.

There are a dialect that every cell can be only in the range of [0, 65536), which we call it Restricted variant. Also, Restricted variant have a variant that wraps at the limit value, which calls Folded variant.

Syntax

Command Table
CMD Things is do
+ Increase the activated cell by 1.
\ Increase the activated cell by 16.
» Increase the activated cell by 256.
- Decrease the activated cell by 1.
/ Decrease the activated cell by 16.
« Decrease the activated cell by 256.
> Inactivates the current cell and activates the cell to its right. In other words, point the pointer to a cell to the right.
< Inactivates the current cell and activates the cell to its left. In other words, point the pointer to a cell to the left.
. Output cell as ASCII character.
: Output cell as a number.
[ Go to corresponding ] if value in stomach is 0.
] Go to corresponding [ if value in stomach isn't 0.
( Start a comment.
) End a comment.
, Get input as a character.
; Get input as a number.
# Quit program immediately.

Thus every Brainfuck program also work in Phi.

Examples

A+B Problem

;>;[-<+>]<:

Bad

,>,[-<+>]<.

Hello, World!

+++++++++++[>++++++>+++++++++>++++++++>++++>+++>+<<<<<<-]>++++++.>++.+++++++..+++.>>.>-.<<-.<.+++.------.--------.>>>+.>-.

Truth machine

;[:]:

Cat program(EOF returns 0)

,[.,]

Error

It's definitely about dealing with errors: when an error is encountered, it outputs a piece of information and then stops.

Memory error

These only work in Restricted variant.

Negative value in any cell:

[Error 1] The value inside the cell must be a natural number that less than 65536.
The program failed to execute.

Value above/equal 65536 in any cell:

[Error 1] The value inside the cell must be a natural number that less than 65536.
The program failed to execute.

Syntax error

Unmatched brackets:

[Error 2] Failed to find matching square brackets.
Compilation failed.

A comment block appears that is not closed:

[Error 3] The comment block must be completely closed.
Compilation failed.

Nothing was entered, or an EOF was entered (if it was not disposed of):

[Error 5] Failed to get the correct input.
The next code won't be executed.

Stack overflow:

[Error 8] Stack overflow.
The program failed to execute.

Miscallenous

Runtime error:

[Error 114514] Runtime error.
The next code won't be executed.

Memory was out:

[Error 1919810] There is not enough memory for code execution.
The program failed to execute.

Internal system error:

[Error -1] ?̨̥͖̪̙͍̞̉͒̾̓̈̌̍͆́͜?̺̦̟͍̖̫̮̖͛̒̓̐̄̿̇̄?̢̨̡̛͎̯̑͌̎̃̉͐͝ͅ?̢̪̭̫̝̠̤̆̋̂̔̍͐̽̔͒?̫͔̫͙͒̌̌̆̂̐̈́͟?̸͙̱͍͖͖̽̾̀͛͐?̸̧͓͔͚̩̎́̄̐̔̏̚?̢̟̫͎͚͕̙̎͌̉̇͑͋̍̑̐͒ͅͅ?̴̢̡̢̱͈͍̗̬̈̿͑̿̐̓͋͒̚͝ͅ?̞̠͖̦̜̩̳̂́̂̀̃͌
Compilation failed.

Successfully runned the program:

[Error 0] Program exits normally and properly.
Successfully runned the program.

Interpreters

Just modify on BAIMS's interpreter.

Categories, Notes, and References