1
0
Fork 0
forked from fun/fun

Added tons of opcode documentation, changed license to ISC and a lot of file refactoring.

This commit is contained in:
Johannes Findeisen 2025-09-16 02:11:22 +02:00
commit d7843274ee
111 changed files with 2597 additions and 26 deletions

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Arrays basics
arr = [1, 2, 3]
print(arr) // -> [1, 2, 3]

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Advanced Arrays Demo
// Start with a basic array

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// for-in over an array literal
for x in [1, 2, 3]
print(x) // prints: 1, then 2, then 3

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Conversions and length built-ins demo
// len on array and string

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Built-ins: strings, array utils, iteration helpers, and math
// Strings

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Maps, map/filter/reduce, labeled break/continue (depth), and file I/O
// Map literal and indexing

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Expressions test: arithmetic, precedence, comparisons, logical ops, unary, parentheses.
print("=== Expressions test start ===")

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// for/range test: globals, nested loops, and a function using range
print("=== for/range test start ===")

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Functions test: definitions, calls, parameters, locals, returns, and if/else.
print("=== Functions test start ===")

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
/*
* Have fun in Fun
*/

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Have fun in Fun
string s = "Have fun!"

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Test else / else if chains and nested if-blocks (two-space indentation)
print("=== if/else-if/else test ===")

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// break and continue examples
// 1) while loop: print odd numbers, stop after printing 7

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Nested loops: break and continue behavior
// 1) Nested for range: inner continue on j==2, inner break on j==4, outer break on i==3

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Objects via maps: bracket access and method calls with explicit self
// Construct an object as a map (attach methods later)

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Objects as maps: nested fields, methods with explicit self
// A method to move a 2D point by dx, dy

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Short-circuit demo for || and &&
print("=== short-circuit demo ===")

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// Strings test: concatenation with variables and literals, functions returning strings
print("=== strings test start ===")

View file

@ -1,5 +1,14 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
// While loops feature test: simple loops, nested with if/else, and functions
print("=== while test start ===")