Notice: Toy is undergoing a complete rewrite for v2. These docs are valid for version 1.x only. A discussion of the upcoming changes can be found here.
Preamble
The Toy programming language is an imperative bytecode-intermediate embedded scripting language. It isn’t intended to operate on its own, but rather as part of another program, the “host”. This process is intended to allow a decent amount of easy customisation by the host’s end user, by exposing logic in script files. Alternatively, binary files in a custom format can be used as well.
The host will provide all of the extensions needed on a case-by-case basis. Script files have the .toy
file extension, while binary files have the .tb
file extension.
The Toy reference implementation can be found on github.
fn makeCounter() { //declare a function like this
var total: int = 0; //declare a variable with a type like this
fn counter(): int { //declare a return type like this
return ++total;
}
return counter; //closures are explicitly supported
}
var tally = makeCounter();
print tally(); //1
print tally(); //2
print tally(); //3
Nifty Features
- Simple C-like syntax
- Bytecode intermediate compilation
- Optional, but robust type system (including
opaque
for arbitrary data) - Functions and types are first-class citizens
- Import native libraries from the host
- Fancy slice notation for strings, arrays and dictionaries
- Can re-direct output, error and assertion failure messages
- Open source under the zlib license
Getting Started
- Quick Start Guide
- Types
- Toy Version Info Library
- Standard Library
- Math Library
- Random Library
- Runner Library
Deep Dive Document
- Theorizing Toy
- Building Toy
- Embedding Toy
- Compiling Toy
- Developing Toy (incomplete, but being expanded)
- Testing Toy
- Roadmapping Toy
Public C API
- repl_tools.h
- drive_system.h
- toy.h
- toy_common.h
- toy_compiler.h
- toy_interpreter.h
- toy_lexer.h
- toy_literal_array.h
- toy_literal_dictionary.h
- toy_literal.h
- toy_memory.h
- toy_parser.h
- toy_reffunction.h
- toy_refstring.h
- toy_scope.h
Game Engine
Note: This section is WIP.
- Game Engine
- Box Version Info Library
- Engine Library
- Node Library
- Input Library
- Music Library
- Sound Library