Kayne Ruse 14653a303f Added 'Toy_String' to 'Toy_Value' structure, read more
To help with storing strings within tables, I've replaced the unused
'_padding' member of 'Toy_String' with 'cachedHash', which is set to
zero on string allocation.

The hash of a string isn't generated and stored until it's actually
needed, as the rope pattern means not every string needs a hash -
hopefully this will save unnecessarily wasted time.

When a hash of a string is needed, the hashing function first checks to
see if that string already has one, and if so, returns it. Again, less
time wasted.

When generating a new string hash, the hashing function takes the
string's type into account, as node-based strings first need their
contents assembled into a simple char buffer.

Other changes include:

* Changed 'TOY_VALUE_TO_*' to 'TOY_VALUE_FROM_*'
* Changed 'TOY_VALUE_IS_EQUAL' to 'TOY_VALUES_ARE_EQUAL'
* Added a missing '#pragma once' to 'toy_print.h'
2024-10-07 17:35:31 +11:00
2024-05-19 03:50:57 +10:00
2024-10-05 12:17:27 +10:00
2024-10-05 12:17:27 +10:00
2024-05-19 03:50:57 +10:00

For the feature complete version 1, click here.

Toy v2.x

The Toy programming language is an imperative, bytecode-interpreted, embeddable scripting language. Rather than functioning independently, it serves as part of another program, the "host". This design allows for straightforward customization by both the hosts developer and end users, achieved by exposing program logic through text files.

This repository holds the reference implementation for Toy version 2.x, written in C.

Nifty Features

  • Simple C-like syntax
  • Intermediate AST representation
  • Strong, but optional type system
  • First-class functions
  • Extensible via external libraries
  • Can re-direct output, error and assertion failure messages
  • Open source under the zlib license

Syntax

print 42; //print is a built-in keyword

//more examples to be added as the features are implemented

Building

Supported platforms are: linux-latest, windows-latest, macos-latest, using GitHub's standard runners.

To build the library, run make source.
To build the library and repl, run make repl.
To build and run the test cases, run make tests.
To build and run the test cases under gdb, run make tests-gdb.

Tools

Coming Soon.

License

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

Contributors and Special Thanks

For a guide on how you can contribute, see CONTRIBUTING.md.

@hiperiondev - v1 Disassembler, v1 porting support and feedback
@add00 - v1 Library support
@gruelingpine185 - Unofficial v1 MacOS support
@solar-mist - v1 Minor bugfixes
The Ratbags - Feedback
@munificent - For writing the book that sparked my interest in langdev

Patreon Supporters

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