Skip to content
Chicken VM written in PHP.
PHP JavaScript C Perl Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
doc CS Aug 14, 2013
examples
src switch to nikic/iter Dec 14, 2013
tests
.gitignore
LICENSE
README.md
chickenasm.sh shortcut chickenasm script Aug 18, 2013
composer.json
composer.lock
phpunit.xml.dist

README.md

chicken-php

chicken

PHP implementation of the Chicken VM, ported from JavaScript.

What is Chicken? It's a language based around one single symbol: chicken. Actually, there are a few tokens: chicken, space and newline. The chicken count of a line corresponds to an opcode.

It roughly translates into a form of assembly. The supported operations are chicken (string), +, -, *, ==, load, store, jump, chars and literal numbers.

The memory model has pointers to the stack itself and input as the first two elements of the stack. Those are followed by the opcodes, delimited by 0. The opcodes then run until the 0 is reached, at which point the head of the stack is returned. Every operation consumes one or more elements, then pushes its result onto the stack.

The reference implementation is written in JavaScript and is a piece of art.

Usage

chicken

Low-level chicken interpreter.

Quine:

$ echo chicken | bin/chicken

Cat:

$ echo chicken | bin/chicken foo <<EOF
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

EOF

To enable debug logging of instructions and stack, pass the --debug option:

$ echo chicken | bin/chicken --debug

eggsemble

Eggsembler. Compiles down to chicken.

Print A:

$ (bin/eggsemble | bin/chicken) <<EOF
push 5
push 13
rooster
bbq
axe
EOF

chickenasm

Compiles ChickenASM to eggsembly.

Print A:

$ (bin/chickenasm | bin/eggsemble | bin/chicken) <<EOF
push 5
push 13
multiply
char
exit
EOF

Count:

$ cat examples/count.cha | bin/chickenasm | bin/eggsemble | bin/chicken 3

99 chickens:

$ cat examples/99chickens.cha | bin/chickenasm | bin/eggsemble | bin/chicken 9

ChickenASM is a different dialect of chicken assembly. This tool allows translating to eggsembly.

References

You can’t perform that action at this time.