wimvanderbauwhede · Codeberg.org

A frugal compiler for a statically typed functional language running on Uxn.

To try this out, you need a Fortran-90 compiler and optionally the Scons build system. The compiler path must be exported using the environment variable $FC.

In the src folder, run ./build.sh or, if you have SCons, scons. This will build an executable funk2tal and put it in bin.

cd src
./build.sh

or

cd src
scons install

To compile the examples, the easiest way is to use the convenience Perl wrapper around the executable, for example:

cd examples
../bin/funktal.pl -c fact.ftal

or

cd examples
../bin/funktal.pl dvd.ftal

The -c option indicates that the Uxn command line VM (uxncli) should be used to execute the code, rather than the graphics-based one (uxnemu). Use the -h to get the available options for funktal.pl.

To only run the actual Funktal compiler, you can do

cd examples
../bin/funk2tal fact.ftal

The generated Uxntal code is printed on standard output. To run it, you need to redirect it to a file and assemble it to bytecode.

If your Funktal program is not using graphics or audio, you can also interpret it directly using my Yaku interpreter. This is written in JavaScript so it needs node.js, deno or another JavaScript interpreter.

Usually you will want to assemble the Uxntal code to bytecode instead.

Assuming you have installed yaku, you can assemble the Uxntal code to a bytecode "rom" using

yaku -a <filename>.tal

Alternatively, get one of the official Uxn assemblers, uxnasm or drifblim.

Once you have the rom, you can run the command-line emulator uxn2 to execute the rom (or uxncli if the application does not use graphics or audio). There are other implementations, see https://100r.co/site/uxn.html for more information.

../bin/funk2tal fact.ftal > fact.tal
uxnasm fact.tal fact.rom
uxncli fact.rom

or use the convience script:

../utils/run.sh fact.ftal

For more details on the language, see SPEC.md and for more on the implementation see DESIGN.md. Or read my blog post on https://wimvanderbauwhede.codeberg.page/articles/funktal/.

Read the original on codeberg.org ↗