Giter Club home page Giter Club logo

funge-plus-plus's Introduction

Funge++

Funge++ is Befunge interpreter originally written by Conlan Wesson in Java for a Programming Language Concepts course with minimal functionality. It has since been converted to C++, supports all Funge-98 instructions and N-dimensional Funge. The Funge++ handprint is 0x464E2B2B (FN++).

Running

The Funge++ executable funge uses the first file argument to load the funge program. The first character of the file is an instruction at (0,0). Each subsequent character is an instruction at X+1. Both carriage returns and line feed (as well as CRLF) are treated as Y+1 and reset X to zero. Form feeds in the file represent Z+1 and reset X and Y to zero. Carriage returns and line feeds following a form feed are ignored (i.e FF may be own its own line).

See the man page for more information.

Higher Dimensions

Vertical Tabs in the file represent 4D+1 and reset X, Y, and Z to zero. Carriage returns and line feeds following a vertical tab are ignored. This is not part of the Funge-98 specification, but provides a simple way to create 4-dimensional funges.

Trefunge frunges can be loaded as funge-lib formatted .fl files.

Higher dimension funges can be loaded as BeQunge formatted .beq files. Loading a .beq file implies -lNFUN.

Features

Native Threads

The split instruction t can use native threads rather than the tick mechanism described in the Funge-98 specification. This mode can be enabled with -fthreads=native.

Auto-Dimensions

The dimensionality (up to 4D) is determined automatically based on the file contents. This can be overriden with the -std argument. Funge-lib formatted files are 3D. Higher dimensions can be determined automatically from BeQunge formatted files with or without the Dimensions directive.

Standard instructions which operate on vectors (g, p, x, ?), operate with vector lengths equal to the number of dimensions detected. This enables those instructions to function in a standardized way in higher-dimension funges. For example, in 4D mode, ? will change the delta to one of 8 possible directions, while x can move in all possible directions.

C-Style Strings

C-style strings can be enabled with -fstrings=c. In this mode, backslashes in strings are not pused to the stack, instead, it and the following character are interpretted as an escape sequence. This happens in one tick. In addition to special characters, this allows quotes and ANSI escape codes in strings.

64-bit

Funge++ stack and funge-space are 64-bit values. For that reason, FPDP numbers use a single stack cell, and LONG numbers are 128-bit.

Fish and Starfish

Funge++ also supports ><> (Fish) and *><> (Starfish). These can be selected using -std=fish or -std=sfish respectively. Alternatively, Funge++ will automatically detect the languge if a .fish or .sf file is loaded.

Errata

High/Low

The Funge-98 specification is inconsistent about the delta of the h and l instructions (catseye/Funge-98#10). Funge++ uses thedefinition in the program flow section, that is h is "delta <- (0,0,1)" and l is "delta <- (0,0,-1)". This makes it compatible with BeQunge and Rc/Funge-98. The -finvert-hl argument flips this behavior.

Fingerprints

Funge++ supports the following fingerprints. These can either be loaded at runtime by the ( instruction, or by specifying the -l command line argument.

Funge++ also supports dynamic Funge fingerprints. When a fingerprint is loaded, Funge++ will search for funge-lib files in the fing directory before loading a built-in fingerprint. This allows users to override the built-in fingerprints. Instructions from dynamic Funges run with the same stack as the IP that called them.

BASE I/O for numbers in other bases.

BITW Bitwise Operators.

BOOL Boolean Operators.

CPLI Complex Integer Extension.

DBUG Debugger Control.

DIRF Directory Functions.

FING Operate on single fingerprint semantics.

FISH ><> and *><> commands.

FIXP Fixed point math functions.

FPDP Double precision floating point.

FPRT Formatted print.

FPSP Single precision floating point.

FRTH Some common forth commands.

HRTI High Resolution Timer Interface.

IIPC Inter IP Communication.

JSTR 3d string vectors.

LONG Long Integers.

MODE Standard Modes.

MODU Modulo Arithmetic Extension.

MVRS Multiverse extension.

NFUN N-Dimensional Funge.

NULL Null Fingerprint.

ORTH Orthogonal Easement Library.

PERL Generic Interface to the Perl Language.

REFC Referenced Cells Extension.

ROMA Roman Numerals.

STRN String functions.

SUBR Subroutine extension.

TERM Terminal extension.

TOYS Standard Toys.

Debugger

The Funge++ debugger, known as defunge, can be run on any Befunge program by specifying the -g command line argument.

See Defunge for details.

funge-plus-plus's People

Contributors

cwesson avatar stasoid avatar tjol avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

tjol stasoid

funge-plus-plus's Issues

REFC failures in rfunge test suite

Split from issue #1

  1. My "REFC" test fails – I suspect this is a concurrency issue rather than a problem with the fingerprint.

The rfunge test case assumes that fingerprints loaded by one IP are carried over into child IPs. The spec has nothing to say on the matter, and I suspect differential testing will show some disagreement on that as well. For what its worth, Mycology tests for both possibilities.

Failures in rfunge test suite

Hi! I'm working on a Funge-98 interpreter in Rust (rfunge), and I thought I'd run a few other quality befunge interpreters over my test suite – including yours!

My expected outputs are generally generated with either cfunge or CCBI; I do test a few finer points that Mycology doesn't cover.

Funge++ fails a few tests which I rather think it should pass; you can try it yourself using my testing script if you like.

The issues (IMHO) are:

  1. "BOOL" fingerprint: The docs say these are logic functions, but in every other implementation they’re bitwise operations.
  2. Concurrency: Funge++ gets out of sync at some point in concurrent2.b98 – maybe the ; ... ; takes a tick?
  3. "HRTI" fingerprint: my test starts the timer, checks the number of sub-second microseconds with S, and then busy-waits until the next second (as determined using y). Now we know that at least 1000000 - (result of S) μs have passed. We then read the timer, add a small margin of error, and check that enough time has indeed passed. This isn't the most robust test, but even on interpreters where it sometimes fails (like pyfunge), it usually works. On Funge++, it practically always fails...
  4. k;: While there is disagreement about whether 0k;@;1 should skip over ;@; or only ;, most interpreters agree that 1k;@;1 should skip over ;@; and execute the 1 twice, not execute @ (which is what Funge++ currently does)
  5. "MODU" fingerprint: I happen to think the behaviour you have chosen (which is the same as several other interpreters) is mathematically absurd. (see https://github.com/tjol/rfunge/wiki/Fingerprints#modu-0x4d4f4455), but I fully accept that this is my least defensible complaint here
  6. My "REFC" test fails – I suspect this is a concurrency issue rather than a problem with the fingerprint.

I know this is a lot for one "issue" – just thought it might be of some interest! :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.