sardaukar / zorkscript

JavaScript (subset) to Infocom Z-Machine compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ZorkScript

The unofficial JavaScript (subset) to Z-machine compiler.

Installation

Using npm

npm i -g npm
npm i -g zorkscript

Usage

Invoke the compiler from the command line...

zsc in.js --out out.z3

...and run the output in an appropriate Z-Machine intepreter, such as Frotz. Binaries are available for (Windows, iPhone, Ubuntu, etc)

Example

An example

const max = 50;
const sieve = Array(51);

// https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
function printPrimes() {
    for (let i = 2; i <= max; ++i) {
        const isMarked = loadb(sieve, i);
        if (isMarked != true) {
            print(' '); print(i);
            for (let j = i * 2; j <= max; j += i) {
                storeb(sieve, j, 1);
            }
        }
    }
}

print('primes: '); printPrimes(); print('\n');

About

JavaScript (subset) to Infocom Z-Machine compiler

License:Apache License 2.0


Languages

Language:TypeScript 100.0%