Skip to content

Commit e07f1b3

Browse files
committed
Added the Squirrel Programming Language
1 parent fd6c736 commit e07f1b3

File tree

8 files changed

+69
-0
lines changed

8 files changed

+69
-0
lines changed
520 Bytes
Loading
2.16 KB
Loading
393 Bytes
Loading

squirrel/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<img src="https://raw.githubusercontent.com/rtoal/polyglot/master/docs/+resources/squirrel-logo-64.png">
2+
3+
# Squirrel Explorations:
4+
5+
Due to a bug with the latest version of Squirrel, you will need to install the Squirrel compiler from a branch of Squirrel 3.2 by downloading the zip file from this [GitHub repo](https://github.com/albertodemichelis/squirrel/tree/f92bc298784ceea459b12e2de33bdff672bfeb83). There, unzip it and follow the instructions in the `COMPILE` file that is in the root folder. Afterwards, copy the path to the bin folder (which is where the executable file is located) and add it to to your environment variables.
6+
7+
If you are sturggling to compile the compiler, you can run Squirrel on [TIO](https://tio.run/#squirrel).
8+
9+
## About Squirrel:
10+
11+
Squirrel is a high-level, imperative, object-oriented scripting language designed to fit within the size, memory bandwith, and real-time requirements for applications, including games. ...
12+
13+
## Squirrel Resources:
14+
15+
Continue your study of Squirrel via:
16+
17+
- [Squirrel GitHub](https://github.com/albertodemichelis/squirrel)
18+
- [Squirrel Documentation](http://www.squirrel-lang.org/squirreldoc/)
19+
- [Squirrel Documentation (Dense)](http://www.squirrel-lang.org/doc/squirrel3.html#d0e45)

squirrel/clockhands.nut

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
for (local i = 0 ; i < 11 ; i++)
2+
{
3+
local t = (43200 * i + 21600) / 11
4+
local h = t / 3600
5+
local m = t / 60 % 60
6+
local s = t % 60
7+
printf("%02d:%02d:%02d\n", h || 12, m, s)
8+
}

squirrel/hello.nut

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello, World!\n")

squirrel/test.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function Assert-MatchTests {
2+
param (
3+
[Parameter(Mandatory = $true, ValueFromPipeline)] $TestResult
4+
)
5+
6+
if ($TestResult) {
7+
Write-Error "Output does not match expected results."
8+
}
9+
}
10+
11+
$Error.clear()
12+
sq "$PSScriptRoot\clockhands.nut" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
15+
sq "$PSScriptRoot\hello.nut" &&
16+
sq "$PSScriptRoot\triple.nut" |
17+
Compare-Object (Get-Content "$PSScriptRoot\..\test\triple_expected") |
18+
Assert-MatchTests &&
19+
ForEach-Object 'foo';
20+
21+
if ($Error -or !$?) {
22+
"*** SQUIRREL TESTS FAILED ***"
23+
}
24+
else {
25+
"SQUIRREL TESTS PASSED"
26+
}
27+
28+

squirrel/triple.nut

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
for (local c = 1; c < 41; c++)
2+
{
3+
for (local b = 1; b < c; b++)
4+
{
5+
for (local a = 1; a < b; a++)
6+
{
7+
if (a * a + b * b == c * c)
8+
{
9+
printf("%d, %d, %d\n", a, b, c)
10+
}
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)