Call Queue/if Call Queue

From Esolang
Jump to navigation Jump to search

This is a dialect (and the implementation of it) of Call Queue called if Call Queue with some atoms defined.

Running

Call Queue.js contains the functions for if Call Queue. The main interpreter function is call_queue() (it's a generator because I want nice stepping and no locking in infinite loops). Here's an example:

var demo = call_queue(`
	function a() { A; c(); d(); }
	function b() { B; e(); f(); }
	function c() { C; }
	function d() { D; }
	function e() { E; }
	function f() { F; }
	function main() { M; a(); b(); }
`);

var result = demo.next().value;
while(result != undefined) {
	output = result.output;
    result = demo.next().value;
}
console.log(output.join("")); // "MABCDEF"

Differences to normal Call Queue

Since no atoms are defined, I took the liberty to define if;, which can be seen here:

function true() {
	1; true();
}

function false() {
	0;
}

function main() {
	if; true;
		true();
		false();
	<put `true;` or `false;` here>
}

If you put true;, it matches the required symbol and calls true(); and for anything else (like false;), it doesn't match the required symbol and calls false();.

All other atoms print themselves.

Legal symbols (function names/function calls/atom calls) are this regex /[A-Za-z_0-9]+/.

Implementation

if Call Queue