Skip to content

Python implementation of an interpreter for the esoteric programming language Befunge.

Notifications You must be signed in to change notification settings

BenDMyers/BefungeInterpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

BefungeIntepreter by Ben Myers

About Befunge

Befunge is a stack-based esoteric programming language created by Chris Pressey in 1993 with the express goal of being as difficult to compile as possible. It attempts this by a) being multidimensional with its grid-based structure and b) by allowing for self-modifying code.

Befunge-93 Specifications:
Instruction Function
0-9 Push this number on the stack
+ Addition: Pop a and b, then push a+b
- Subtraction: Pop a and b, then push b-a
* Multiplication: Pop a and b, then push a*b
/ Integer division: Pop a and b, then push b/a, rounded towards 0
% Modulo: Pop a and b, then push b%a
! Logical NOT: Pop a value, then push 1 if the value is a zero and 0 otherwise
` Greater than: Pop a and b, then push 1 if b>a and 0 otherwise
> Start moving right
< Start moving left
^ Start moving up
v Start moving down
? Start moving in a random cardinal direction
_ Pop a value, and move right if it's zero, and left otherwise
| Pop a value, and move down if it's zero, and up otherwise
" Start string mode: push each character's ASCII value all the way up until the next "
: Duplicate the value on top of the stack
\ Swap two values on top of the stack
$ Pop value from the top of the stack and discard it
. Pop value and output as an integer followed by a space
, Pop value and output as ASCII character
# Bridge: Skip next cell
p A "put" call: Pop y, x, and v, then change the character at (x,y) to v
g A "get" call: Pop y and x, then push ASCII value of the character at that position in the program
& Ask user for a number and push it
~ Ask user for a character and push its ASCII value
@ End the program
No-op
A "Hello World!" Program in Befunge-93:
>              v
v  ,,,,,"Hello"<
>48*,          v
v,,,,,,"World!"<
>25*,@

TODO:

  • Implement Funge-98 specifications

    • Dynamic grid sizing

    • The [ ("turn left") and ] ("turn right") instructions

    • User should be able to specify Befunge-93 or Funge-98

  • Implement GUI

About

Python implementation of an interpreter for the esoteric programming language Befunge.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages