Kayne Ruse ea584d8950 Fixed the failing build on mingw
Squashed commit of the following:

commit c48929d25a84331ca8bd1b27be2c6aa4f3b4db12
Author: Kayne Ruse <kayneruse@gmail.com>
Date:   Fri Aug 9 23:12:49 2024 +1000

    Update c-cpp.yml

    I'm only going a little bit nuts.

commit 3f65882bdc75f1712c9a3c9d2ddf0e53a27ce4b9
Author: Kayne Ruse <kayneruse@gmail.com>
Date:   Fri Aug 9 22:49:18 2024 +1000

    Update c-cpp.yml

    It would be great if this was documented better.

commit d3abeda7c2776bb2e82ca635cd659967afa6ad75
Author: Kayne Ruse <kayneruse@gmail.com>
Date:   Fri Aug 9 21:40:39 2024 +1000

    Bumped license date

commit 17bbce9d7ca212064bc95e467933c5602a89fb4c
Author: Kayne Ruse <kayneruse@gmail.com>
Date:   Fri Aug 9 21:33:57 2024 +1000

    Fixed the failing build on mingw

    There seems to be persistent issues with different compilers
    displaying the values of size_t, so I simply cast it to an integer.

commit 843a76d0ac44328776f8ecf83a66caa7ea7fdef6
Author: Kayne Ruse <kayneruse@gmail.com>
Date:   Fri Aug 9 21:17:17 2024 +1000

    Updated CI

commit 08cd89c58d8d028438b9f83a60f5dd9265cc3465
Author: Kayne Ruse <kayneruse@gmail.com>
Date:   Fri Aug 9 21:09:03 2024 +1000

    Why did that fail last time?
2024-08-09 23:25:56 +10:00
2024-08-09 23:25:56 +10:00
2024-07-20 16:27:07 +10:00
2024-08-09 23:25:56 +10:00
2023-08-22 00:43:48 +10:00
2023-08-22 18:23:27 -03:00
2024-08-09 23:25:56 +10:00
2022-08-03 07:39:50 +01:00

Toy

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.

This is the Toy programming language interpreter, written in C.

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

Building

For Windows(mingw32 & cygwin), Linux and MacOS, simply run make in the root directory.

For Windows(MSVC), Visual Studio project files are included.

Note: MacOS and Windows(MSVC) are not officially supported, but we'll do our best!

Tools

Run make install-tools to install a number of tools, including:

  • VSCode syntax highlighting

Other tools such as a disassembler are available, as well - simply run make in the correct directory.

Syntax

import standard; //for a bunch of utility functions

print "Hello world"; //"print" is a keyword

var msg = "foobar"; //declare a variable like this

assert true, "This message won't be seen"; //assert is another keyword

//-------------------------

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

License

This source code is covered by the zlib license (see LICENSE.md).

Contributions

@hiperiondev - Disassembler, porting support and feedback
@add00 - Library support
@gruelingpine185 - Unofficial MacOS support
@solar-mist - Minor bugfixes
Unnamed Individuals - Feedback

Patrons via Patreon

  • Seth A. Robinson

Special thanks to http://craftinginterpreters.com/ for their fantastic book that set me on this path.

Languages
C 97.7%
Makefile 2.2%