~rabbits/orca-toy

a162f0769446820479a882f24845a57896e42a80 — neauoire 2 years ago 454a771
Diffing results
6 files changed, 46 insertions(+), 9 deletions(-)

M README.md
A abflm-expected.orca
A abflm-result.orca
A abflm.orca
M build.sh
M toy.c
M README.md => README.md +2 -1
@@ 2,7 2,7 @@

Orca is an [esoteric programming language](https://en.wikipedia.org/wiki/Esoteric_programming_language) designed to quickly create procedural sequencers, in which every letter of the alphabet is an operation, where lowercase letters operate on bang, uppercase letters operate each frame.

This is a single-file toy implementation, written in ANSI C, of the basic operators created for educational purposes.
This is a single-file implementation of the basic operators created for educational purposes. To try a complete environment with client and server, see [Orca](https://git.sr.ht/~rabbits/orca).

## Operators



@@ 36,3 36,4 @@ To display the list of operators inside of Orca, use `CmdOrCtrl+G`.
- `Z` **lerp**(*rate* target): Transitions operand to input.
- `*` **bang**: Bangs neighboring operands.
- `#` **comment**: Halts a line.


A abflm-expected.orca => abflm-expected.orca +10 -0
@@ 0,0 1,10 @@
.A.aA..AaaAa1AA2AZ
.0..a..a..k..B..1.
.B.aB..BaaBa1BA2BZ
.0..a..a..0..9..X.
.F.aF..FaaFa1FAzFZ
.*........*.......
.L.aL..LaaLa1LAzLZ
..........a..1..Z.
.M.aM..MaaMa1MAzMZ
.0..0..0..s..A..1.

A abflm-result.orca => abflm-result.orca +10 -0
@@ 0,0 1,10 @@
.A.aA..AaaAa1AA2AZ
.0..a..a..k..B..1.
.B.aB..BaaBa1BA2BZ
.0..a..a..0..9..X.
.F.aF..FaaFa1FAzFZ
..................
.L.aL..LaaLa1LAzLZ
..................
.M.aM..MaaMa1MAzMZ
..................

A abflm.orca => abflm.orca +10 -0
@@ 0,0 1,10 @@
.A.aA..AaaAa1AA2AZ
..................
.B.aB..BaaBa1BA2BZ
..................
.F.aF..FaaFa1FAzFZ
..................
.L.aL..LaaLa1LAzLZ
..................
.M.aM..MaaMa1MAzMZ
..................

M build.sh => build.sh +2 -1
@@ 10,4 10,5 @@ cc -std=c89 -DDEBUG -Wall -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werr
# Plan9
# pcc toy.c -o toy

./toy demo.orca
./toy abflm.orca > abflm-result.orca
diff abflm-result.orca abflm-expected.orca
\ No newline at end of file

M toy.c => toy.c +12 -7
@@ 86,11 86,6 @@ void
parse(Grid *g)
{
	int i, x, y;
	printf("F0\n");
	for(i = 0; i < g->l; ++i) {
		printf("%c", g->data[i]);
	}
	printf("DEBUG\n");
	for(i = 0; i < g->l; ++i) {
		char c = g->data[i];
		x = i % g->w;


@@ 113,6 108,18 @@ parse(Grid *g)
				set(g, x + 1, y, 'E');
				lock(g, x + 1, y);
			}
		} else if(c == 'F') {
			/* TODO */
			lock(g, x + 1, y);
			lock(g, x, y + 1);
		} else if(c == 'L') {
			/* TODO */
			lock(g, x + 1, y);
			lock(g, x, y + 1);
		} else if(c == 'M') {
			/* TODO */
			lock(g, x + 1, y);
			lock(g, x, y + 1);
		} else if(c == 'N') {
			if(y == 0 || get(g, x, y - 1) != '.')
				set(g, x, y, '*');


@@ 139,7 146,6 @@ parse(Grid *g)
			}
		}
	}
	printf("F1\n");
	for(i = 0; i < g->l; ++i) {
		printf("%c", g->data[i]);
	}


@@ 158,7 164,6 @@ load(FILE *f, Grid *g)
		}
		g->data[g->l++] = c;
	}
	printf("grid:%d(%dx%d)\n", g->l, g->w, g->h);
	parse(g);
}