Skip to content

Quakken/goat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

   ____    U  ___ u    _       _____   
U /"___|u   \/"_ \/U  /"\  u  |_ " _|  
\| |  _ /   | | | | \/ _ \/     | |    
 | |_| |.-,_| |_| | / ___ \    /| |\   
  \____| \_)-\___/ /_/   \_\  u |_|U   
  _)(|_       \\    \\    >>  _// \\_  
 (__)__)     (__)  (__)  (__)(__) (__)

Eat the code

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.

Example: Hello world

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

Actions

See also: Actions, STOMACH

I/O

  • munch - Eat the first word of the program
  • bleat - Print the first word in your STOMACH
  • blech - Print the first word in your STOMACH to the start of the program

Flow control

  • do...repeat - Repeat a block of code
  • ponder...end - Execute a block of code only if the first word in your STOMACH is deemed acceptable

STOMACH manipulation

  • digest - Erase the first value in your STOMACH
  • chew - Decrement the first value in your STOMACH
  • savor - Increment the first value in your STOMACH

Arithmetic

Goats can't do math.

Getting Started

See also: First Steps

Building the CLI

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]

Embedding

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-

About

The GOAT programming language. Code is food. Source is full.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors