mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Stripped back docs website
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
layout: page
|
|
||||||
---
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
layout: page
|
|
||||||
---
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
22
_config.yml
22
_config.yml
@@ -2,25 +2,3 @@ title: The Toy Programming Language
|
|||||||
description: Documentation For The Toy Programming Language
|
description: Documentation For The Toy Programming Language
|
||||||
keywords: programming,coding
|
keywords: programming,coding
|
||||||
author: Kayne Ruse (Ratstail91)
|
author: Kayne Ruse (Ratstail91)
|
||||||
|
|
||||||
collections:
|
|
||||||
getting_started:
|
|
||||||
output: true
|
|
||||||
title: Getting Started
|
|
||||||
permalink: "/:collection/:path/"
|
|
||||||
tab-order: 1
|
|
||||||
toy_api:
|
|
||||||
output: true
|
|
||||||
title: Toy API
|
|
||||||
permalink: "/:collection/:path/"
|
|
||||||
tab-order: 2
|
|
||||||
c_api:
|
|
||||||
output: true
|
|
||||||
title: C API
|
|
||||||
permalink: "/:collection/:path/"
|
|
||||||
tab-order: 3
|
|
||||||
|
|
||||||
plugins:
|
|
||||||
- jekyll-remote-theme
|
|
||||||
|
|
||||||
remote_theme: pixeldroid/programming-pages
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
layout: page
|
|
||||||
title: Contributions
|
|
||||||
order: 4
|
|
||||||
---
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
---
|
|
||||||
layout: page
|
|
||||||
title: Toy v2 Quick-Start Guide
|
|
||||||
order: 1
|
|
||||||
---
|
|
||||||
|
|
||||||
# Toy v2 Quick-Start Guide
|
|
||||||
|
|
||||||
To help you start using Toy as fast as possible, here are the most useful elements of the language. Not everything available is listed, but this should let you start coding right away.
|
|
||||||
|
|
||||||
## Keyword 'print'
|
|
||||||
|
|
||||||
The `print` keyword takes one value as a parameter, which is sent to stdout by default, or can be redirected elsewhere using the [output C API](/c_api/output).
|
|
||||||
|
|
||||||
```
|
|
||||||
print "Hello World!";
|
|
||||||
```
|
|
||||||
|
|
||||||
## Keyword 'assert'
|
|
||||||
|
|
||||||
The `assert` keyword takes two values as parameters, separated by a comma. If the first value is falsy or `null`, the optional second parameter is sent to stderr by default, or can be redirected elsewhere using the [output C API](/c_api/output). If no second parameter is provided, a generic message is used instead.
|
|
||||||
|
|
||||||
An option to disable the `assert` keyword during compilation is provided in the [parser C API](/c_api/parser).
|
|
||||||
|
|
||||||
```
|
|
||||||
//nothing happens
|
|
||||||
assert 1 < 2;
|
|
||||||
|
|
||||||
//this assert will fail, and output the second parameter
|
|
||||||
assert null, "Hello world!";
|
|
||||||
```
|
|
||||||
|
|
||||||
## Variables and Types
|
|
||||||
|
|
||||||
Values can be stored in variables, by specifying a name with the `var` keyword. The name can be declared with an optional type, which restricts the type of value that can be stored in the name. If no type is specified, `any` is used instead.
|
|
||||||
|
|
||||||
```
|
|
||||||
var answer = 42;
|
|
||||||
|
|
||||||
var question: string = "How many roads must a man walk down?";
|
|
||||||
```
|
|
||||||
|
|
||||||
To make a variable immutable, you can add the `const` keyword after the type when it's declared. If you do, it must be assigned a value.
|
|
||||||
|
|
||||||
```
|
|
||||||
var quote: string const = "War. War never changes.";
|
|
||||||
```
|
|
||||||
|
|
||||||
The types available in Toy are:
|
|
||||||
|
|
||||||
| type | name | description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| `bool` | boolean | Either `true` or `false`. |
|
|
||||||
| `int` | integer | Any whole number (32-bits). |
|
|
||||||
| `float` | float | A decimal number (32-bits), using floating-point arithmetic. |
|
|
||||||
| `string` | string | A piece of text, supports UTF-8, [in theory](https://github.com/krgamestudios/Toy/issues/174). |
|
|
||||||
| `array` | array | A series of values stored sequentially in memory. |
|
|
||||||
| `table` | table | A series key-value pairs stored in such a way that allows for fast lookups. Booleans, functions, opaques and `null` can't be used as keys. |
|
|
||||||
| `function` | function | A chunk of reusable code that takes zero or more parameters, and returns zero or more results. Functions are declared with the `fn` keyword. |
|
|
||||||
| `opaque` | opaque | This value is unusable in the script, but can be passed from one imported function to another. |
|
|
||||||
| `any` | any | The default type when nothing is specified. Theis can hold any value. |
|
|
||||||
|
|
||||||
*Note: Arrays, tables, functions and opaques are not fully implemented at the time of writing, so details may change.*
|
|
||||||
|
|
||||||
## Control Flow
|
|
||||||
|
|
||||||
Choosing an option, or repeating a chunk of code multiple times, is essential for any general purpose language.
|
|
||||||
|
|
||||||
Choosing between two options can be done with the `if-then-else` else statement. If the condition is truthy, the 'then-branch' will be executed. Otherwise, the optional 'else-branch' is executed instead.
|
|
||||||
|
|
||||||
```
|
|
||||||
var answer = 42;
|
|
||||||
|
|
||||||
if (answer < 56) {
|
|
||||||
print "Cod dang it!";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print "Something's fishy here...";
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
var challenge = "hard";
|
|
||||||
|
|
||||||
if (challenge == "hard") {
|
|
||||||
print "I choose to build a scripting language, not because it's easy, but because it's hard!";
|
|
||||||
}
|
|
||||||
|
|
||||||
//the else-branch is optional
|
|
||||||
```
|
|
||||||
|
|
||||||
To repeat a certain action, use the `while-then` loop, which repeats the body as long as the condition is true at the beginning of each loop.
|
|
||||||
|
|
||||||
```
|
|
||||||
var loops = 0;
|
|
||||||
|
|
||||||
while (loops++ < 8) {
|
|
||||||
print "These episodes are endless.";
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
To break out of a loop, you can use the `break` keyword. Alternatively, to restart the loop early, use the `continue` keyword.
|
|
||||||
|
|
||||||
```
|
|
||||||
var loops = 0;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
if (++loops < 15532) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
break; //poor yuki ;_;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
*Note: The `for` loop is coming, eventually, but isn't vital right now.*
|
|
||||||
|
|
||||||
## Arrays and Tables
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
|
|
||||||
## External Libraries and Extending Toy
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
|
|
||||||
## Reserved Keywords & Operators
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
layout: page
|
|
||||||
title: Syntax Guide
|
|
||||||
order: 2
|
|
||||||
---
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
layout: page
|
|
||||||
title: Tools Guide
|
|
||||||
order: 3
|
|
||||||
---
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<table class="ui unstackable very basic collapsing table">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td class="smaller text">
|
|
||||||
<div style="margin-top: -1em; padding-left: 5px;">
|
|
||||||
<img src="assets/blacktocat.png" style="filter: invert(100%); height: 20px; margin: 0 5px -5px -5px;">
|
|
||||||
<a href="https://github.com/krgamestudios/Toy">Available On GitHub</a>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="smaller text">
|
|
||||||
GH Pages Theme adapted from <a href="{{ layout.theme_url }}" title="a jekyll theme for publishing code documentation to GitHub pages">Programming Pages</a>.
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<div style="float:right; padding: 1em;" onclick="chicken();" title="Cluck me!">
|
|
||||||
<script type="text/javascript">
|
|
||||||
let options = [
|
|
||||||
"What the cluck?",
|
|
||||||
"Go cluck yourself!",
|
|
||||||
"I don't give a cluck!",
|
|
||||||
"Cluck off!",
|
|
||||||
"That farmer clucked me over!"
|
|
||||||
];
|
|
||||||
function chicken() {
|
|
||||||
document.getElementById("chirp").textContent = options[ Math.floor(options.length * Math.random()) ];
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<p><span id="chirp"></span> 🐔</p>
|
|
||||||
</div>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<a class="borderless toggle item">{% include icon.liquid id='bars' %} Menu</a>
|
|
||||||
|
|
||||||
<a class="borderless item" href="{{ site.baseurl }}/">{% include icon.liquid id='home' %} Home</a>
|
|
||||||
|
|
||||||
<div class="borderless header item">
|
|
||||||
<span class="larger text custom-mobile-hide">{{ site.title }}</span>
|
|
||||||
</div>
|
|
||||||
13
_includes/metadata.html
Normal file
13
_includes/metadata.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<!-- site information -->
|
||||||
|
<meta name="description" content="{{ site.description }}" />
|
||||||
|
<meta name="author" content="{{ site.author }}" />
|
||||||
|
<meta name="keywords" content="{{ site.keywords }}" />
|
||||||
|
|
||||||
|
<!-- facebook -->
|
||||||
|
<meta property="og:url" content="{{ site.url }}" />
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
|
<meta property="og:image" content="{{ site.baseurl }}/assets/repo-preview.png" />
|
||||||
|
<meta property="og:title" content="{{ page.title }}" />
|
||||||
|
<meta property="og:description" content="{{ page.description }}" />
|
||||||
|
|
||||||
|
<link rel="icon" href="{{ site.baseurl }}/favicon.png">
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
@media only screen and (max-width: 768px) {
|
|
||||||
.custom-mobile-hide {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ui.segment {
|
|
||||||
overflow-x: unset;
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
---
|
|
||||||
layout: compress
|
|
||||||
---
|
|
||||||
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
|
|
||||||
<!-- device settings -->
|
|
||||||
<meta charset = "UTF-8" />
|
|
||||||
<meta name="Content-Type" content="text/html" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
|
|
||||||
<!-- page title -->
|
|
||||||
<title>{{ page.title }}</title>
|
|
||||||
|
|
||||||
<!-- theme and styling -->
|
|
||||||
<style>svg.icon{width:1em;height:1em}</style>
|
|
||||||
<link rel="preload" as="style" href="{{ site.baseurl }}/assets/site.css" onload="this.onload=null;this.rel='stylesheet';">
|
|
||||||
<noscript><link rel="stylesheet" href="{{ site.baseurl }}/assets/site.css"></noscript>
|
|
||||||
<script>{% include scripts/loadcss/loadcss-2.0.1.min.js %}</script>
|
|
||||||
|
|
||||||
<!-- site information -->
|
|
||||||
<meta name="description" content="{{ site.description }}" />
|
|
||||||
<meta name="author" content="{{ site.author }}" />
|
|
||||||
<meta name="keywords" content="{{ site.keywords }}" />
|
|
||||||
|
|
||||||
<!-- facebook -->
|
|
||||||
<meta property="og:url" content="{{ site.url }}" />
|
|
||||||
<meta property="og:type" content="website" />
|
|
||||||
<meta property="og:image" content="{{ site.baseurl }}/assets/repo-preview.png" />
|
|
||||||
<meta property="og:title" content="{{ page.title }}" />
|
|
||||||
<meta property="og:description" content="{{ page.description }}" />
|
|
||||||
|
|
||||||
<!-- twitter -->
|
|
||||||
<meta name="twitter:card" content="{{ site.title }}" />
|
|
||||||
<meta name="twitter:url" content="{{ site.url}}" />
|
|
||||||
<meta name="twitter:type" content="website" />
|
|
||||||
<meta name="twitter:image" content="{{ site.baseurl }}/assets/repo-preview.png" />
|
|
||||||
<meta name="twitter:title" content="{{ page.title }}" />
|
|
||||||
<meta name="twitter:description" content="{{ page.description }}" />
|
|
||||||
|
|
||||||
<script src="{{ site.baseurl }}/assets/site.js"></script>
|
|
||||||
<link rel="icon" href="{{ site.baseurl }}/favicon.png">
|
|
||||||
|
|
||||||
{% include elements/analytics.html %}
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
{{ content }}
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
21
_layouts/default.html
Normal file
21
_layouts/default.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<!-- device settings -->
|
||||||
|
<meta charset = "UTF-8" />
|
||||||
|
<meta name="Content-Type" content="text/html" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
|
<!-- page title -->
|
||||||
|
<title>{{ page.title }}</title>
|
||||||
|
|
||||||
|
{% include metadata.html %}
|
||||||
|
{% include analytics.html %}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
{{ content }}
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
---
|
|
||||||
layout: base
|
|
||||||
theme_version: 0.5.22
|
|
||||||
theme_url: https://github.com/pixeldroid/programming-pages
|
|
||||||
---
|
|
||||||
|
|
||||||
<!-- top menu -->
|
|
||||||
<div id="site-title" class="ui top fixed menu">
|
|
||||||
{% include elements/title.html %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- animated sidebar (can be revealed in mobile view) -->
|
|
||||||
<div id="sidebar-retractable" class="ui vertical inverted sidebar menu">
|
|
||||||
<!-- #sidebar-collection-indices is re-parented here for mobile view -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- pushing container (will be pushed right when retractable sidebar opens) -->
|
|
||||||
<div class="pusher">
|
|
||||||
|
|
||||||
<div class="ui left attached internal rail">
|
|
||||||
<!-- static sidebar (visible in non-mobile view) -->
|
|
||||||
<div id="sidebar-fixed" class="ui vertical inverted menu">
|
|
||||||
<div id="sidebar-collection-indices">
|
|
||||||
{% include elements/indices.html %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- main contents -->
|
|
||||||
<div id="page-container">
|
|
||||||
<div class="ui left aligned fluid container">
|
|
||||||
<div id="page-content" class="ui basic segment" style="max-width: 840px; margin-bottom: 6em;">
|
|
||||||
{{ content }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- The style attribute here, and in the div above, ensure the footer works as expected -->
|
|
||||||
<!-- footer -->
|
|
||||||
<div id="site-attribution" class="ui basic segment" style="position: absolute; bottom: 0">
|
|
||||||
{% include elements/attribution.html %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- help modal -->
|
|
||||||
<div id="site-help" class="ui small modal">
|
|
||||||
{% include elements/help.html %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
{% include scripts/indices.js %}
|
|
||||||
{% include scripts/search.js %}
|
|
||||||
{% include scripts/page.js %}
|
|
||||||
{% include scripts/help.js %}
|
|
||||||
|
|
||||||
{% comment %} provide user extension / override point {% endcomment %}
|
|
||||||
{% include scripts/custom.js %}
|
|
||||||
</script>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
layout: page
|
|
||||||
---
|
|
||||||
|
|
||||||
Watch this space.
|
|
||||||
14
index.md
14
index.md
@@ -3,8 +3,6 @@ layout: page
|
|||||||
title: The Toy Programming Language
|
title: The Toy Programming Language
|
||||||
---
|
---
|
||||||
|
|
||||||
{% include elements/chicken.html %}
|
|
||||||
|
|
||||||
<div style="justify-self: center;">
|
<div style="justify-self: center;">
|
||||||
<image src="assets/toylogo.png" width="250" height="250" />
|
<image src="assets/toylogo.png" width="250" height="250" />
|
||||||
</div>
|
</div>
|
||||||
@@ -15,15 +13,5 @@ title: The Toy Programming Language
|
|||||||
|
|
||||||
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 host's developers and end users, achieved by exposing program logic through text files.
|
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 host's developers and end users, achieved by exposing program logic through text files.
|
||||||
|
|
||||||
This website presents the documentation for Toy version 2.x.
|
The documdentation on this website is under construction, for further information, see the repository on GitHub: [https://github.com/krgamestudios/Toy](https://github.com/krgamestudios/Toy).
|
||||||
|
|
||||||
## Nifty Features
|
|
||||||
|
|
||||||
* Simple C-like/JS-like syntax
|
|
||||||
* Intermediate AST representation
|
|
||||||
* Strong, but optional type system
|
|
||||||
* First-class functions and closures
|
|
||||||
* Extensible with importable native code
|
|
||||||
* Can re-direct output, error and assert failure messages
|
|
||||||
* Open-Source under the zlib license
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user