Kayne Ruse 1dde9d8f29 Improved error message in set() and push()
The actual issue was that the type check wasn't catching the issue, so
it reached the scope before it was caught. Fixed it, anyway.
2023-02-20 13:04:35 +00:00
2023-02-09 17:25:24 +00:00
2023-02-14 16:05:43 +00:00
2023-01-11 20:48:47 +00:00
2023-02-10 21:53:38 +00:00
2023-02-11 06:48:16 +00:00
2023-02-14 18:55:24 +00:00
2023-02-14 18:03:04 +00:00
2022-08-03 07:39:50 +01:00

Toy

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

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

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 external libraries
  • 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

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).

Patrons via Patreon

  • Seth A. Robinson
Languages
C 97.7%
Makefile 2.2%