mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Testing the documentation process
This commit is contained in:
64
README.md
64
README.md
@@ -2,68 +2,24 @@
|
||||
<image src="toylogo.png" />
|
||||
</p>
|
||||
|
||||
# Toy 0.6.0
|
||||
The Toy programming language is a procedural bytecode-intermediate interpreted language. It isn't intended to operate on it's 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.
|
||||
|
||||
This is the Toy programming language interpreter, written in C.
|
||||
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.
|
||||
|
||||
Special thanks to http://craftinginterpreters.com/ for their fantastic book that set me on this path.
|
||||
|
||||
## Nifty Features
|
||||
# Nifty Features
|
||||
|
||||
* Simple C-like syntax
|
||||
* Bytecode intermediate compilation
|
||||
* `import` and `export` variables from the host program
|
||||
* Optional, but robust type system
|
||||
* functions and types are first-class citizens
|
||||
* Fancy slice notation for strings, arrays and dictionaries (`print greeting[0:4:-1]; //prints "olleh"`)
|
||||
* Fancy slice notation for strings, arrays and dictionaries
|
||||
|
||||
## Building
|
||||
# Getting Started
|
||||
|
||||
Simply run make in the root directory.
|
||||
* [Quick Start Guide](quick-start-guide)
|
||||
* [Tutorials](tutorials)
|
||||
* [Types](types)
|
||||
* [Functions](functions)
|
||||
* [Developing With Toy](developing-with-toy)
|
||||
|
||||
## 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
|
||||
|
||||
export tally; //export this variable to the host program
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
Copyright (c) 2020-2022 Kayne Ruse, KR Game Studios
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
Reference in New Issue
Block a user