____ U ___ u _ _____
U /"___|u \/"_ \/U /"\ u |_ " _|
\| | _ / | | | | \/ _ \/ | |
| |_| |.-,_| |_| | / ___ \ /| |\
\____| \_)-\___/ /_/ \_\ u |_|U
_)(|_ \\ \\ >> _// \\_
(__)__) (__) (__) (__)(__) (__)
GOAT is a lightweight scripting language that gives you full control over the mind of a virtual, source-code-consuming goat.
GOAT is not statically typed. In fact, GOAT has no concept of a variable. GOAT programs will never crash, because goats are very resilient creatures.
Unlike many other languages, most GOAT programs can only be run once. Unlike many other languages, GOAT considers this a feature.
hello world! 0
do
munch eat the first word of the program
blech spit it back out (but keep a copy in your STOMACH)
ponder determine if it's a zero
munch if not, eat it again
digest get rid of the second copy
bleat scream
repeat repeat until a zero is eaten
end
munch- Eat the first word of the programbleat- Print the first word in your STOMACHblech- Print the first word in your STOMACH to the start of the program
do...repeat- Repeat a block of codeponder...end- Execute a block of code only if the first word in your STOMACH is deemed acceptable
digest- Erase the first value in your STOMACHchew- Decrement the first value in your STOMACHsavor- Increment the first value in your STOMACH
Goats can't do math.
See also: First Steps
Requirements
- CMake v3.30+
- Your favorite C++11 compiler
mkdir build
cd build
cmake ..
cmake --build . --config Release
Usage: goat [path/to/your/script.goat]
GOAT provides a simple, single-header C++ API for use as an embedded language. Just add goat.hpp to your project and define GOAT_IMPLEMENTATION before including it in one of your sources.
#define GOAT_IMPLEMENTATION
#include <goat/goat.hpp>
#include <iostream>
void myCommand(goat::InterpretData &data) { std::cout << "Hello from C++!\n"; }
int main() {
// Create a virtual machine
goat::VM vm{};
// Bind custom actions
vm.bindAction("hello", myCommand);
// ...
// Run your code!
vm.process("10 munch do ponder hello chew repeat end");
// or alternatively...
vm.processFile("myScript.goat");
}
__MMM__ ((__)) ()_() ((__)) __MMM__
(o o) (00) (o o) (00) (o o)
ooO--(_)--Ooo-nn--(o__o)--nn-ooO--`o'--Ooo-nn--(o__o)--nn-ooO--(_)--Ooo-