Fixed the code style in *.c files to two spaces indentation and add a linter named funstx to Fun. (0.39.0)
This commit is contained in:
parent
33001a7ad2
commit
03b2532474
237 changed files with 17550 additions and 13911 deletions
|
|
@ -1,24 +1,24 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*/
|
||||
|
||||
/*
|
||||
* Arrays Example
|
||||
*
|
||||
* Demonstrates basic array operations including:
|
||||
* - Array declaration and initialization
|
||||
* - Accessing elements via indexing
|
||||
* - Iterating through arrays with `for` loops
|
||||
* - Creating subarrays (slices)
|
||||
*- Length calculation
|
||||
*/
|
||||
* Arrays Example
|
||||
*
|
||||
* Demonstrates basic array operations including:
|
||||
* - Array declaration and initialization
|
||||
* - Accessing elements via indexing
|
||||
* - Iterating through arrays with `for` loops
|
||||
* - Creating subarrays (slices)
|
||||
*- Length calculation
|
||||
*/
|
||||
|
||||
// Arrays basics
|
||||
arr = [1, 2, 3]
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*/
|
||||
|
||||
/*
|
||||
* Array Iteration Examples
|
||||
*
|
||||
* Focuses specifically on:
|
||||
* - Various iteration methods (`for`, `while`)
|
||||
* - Using array mapping functions
|
||||
* - Filtering arrays based on conditions
|
||||
* - Reducing arrays to computed values
|
||||
*- Converting between different collection types during iteration
|
||||
*/
|
||||
* Array Iteration Examples
|
||||
*
|
||||
* Focuses specifically on:
|
||||
* - Various iteration methods (`for`, `while`)
|
||||
* - Using array mapping functions
|
||||
* - Filtering arrays based on conditions
|
||||
* - Reducing arrays to computed values
|
||||
*- Converting between different collection types during iteration
|
||||
*/
|
||||
|
||||
// for-in over an array literal
|
||||
for x in [1, 2, 3]
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-13
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-13
|
||||
*/
|
||||
|
||||
/*
|
||||
* Base64 usage demo (RFC 4648, standard alphabet)
|
||||
*
|
||||
* Run without installing:
|
||||
* FUN_LIB_DIR="$(pwd)/lib" ./build/fun examples/base64_demo.fun
|
||||
*/
|
||||
* Base64 usage demo (RFC 4648, standard alphabet)
|
||||
*
|
||||
* Run without installing:
|
||||
* FUN_LIB_DIR="$(pwd)/lib" ./build/fun examples/base64_demo.fun
|
||||
*/
|
||||
|
||||
#include <encoding/base64.fun>
|
||||
|
||||
print("=== Base64 demo ===")
|
||||
print("=== Base64 demo ===")
|
||||
|
||||
// Bytes for the ASCII string "Hello"
|
||||
bytes = [0x48, 0x65, 0x6c, 0x6c, 0x6f]
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-29
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-29
|
||||
*/
|
||||
|
||||
/*
|
||||
Build:
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-12-09
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-12-09
|
||||
*/
|
||||
|
||||
// Simple stopwatch using DateTime helpers
|
||||
#include <utils/datetime.fun>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-12-11
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-12-11
|
||||
*/
|
||||
|
||||
// Demonstrates usage of RANDOM_SEED and RANDOM_INT opcodes via
|
||||
// the built-ins: random_seed(seed) and random_int(lo, hiExclusive).
|
||||
|
|
@ -76,6 +76,6 @@ true
|
|||
true
|
||||
Max seen in [10,20) over 100 samples:
|
||||
19
|
||||
Is max_seen < hi?
|
||||
Is max_seen < hi?
|
||||
1
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,36 +1,36 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-27
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-27
|
||||
*/
|
||||
|
||||
/*
|
||||
* Rust-backed opcode demo: rust_hello()
|
||||
*
|
||||
* Build instructions:
|
||||
* - Default builds disable Rust integration.
|
||||
* - Enable it via: cmake -S . -B build_debug -DFUN_WITH_RUST=ON
|
||||
* - Then: cmake --build build_debug --target fun
|
||||
*
|
||||
* Run:
|
||||
* build_debug/fun examples/rust_hello.fun
|
||||
*
|
||||
* Expected output (with FUN_WITH_RUST=ON):
|
||||
* Hello from Rust ops!
|
||||
*
|
||||
* If built without Rust, calling rust_hello() will raise a runtime error
|
||||
* explaining that Rust integration is disabled.
|
||||
*/
|
||||
* Rust-backed opcode demo: rust_hello()
|
||||
*
|
||||
* Build instructions:
|
||||
* - Default builds disable Rust integration.
|
||||
* - Enable it via: cmake -S . -B build_debug -DFUN_WITH_RUST=ON
|
||||
* - Then: cmake --build build_debug --target fun
|
||||
*
|
||||
* Run:
|
||||
* build_debug/fun examples/rust_hello.fun
|
||||
*
|
||||
* Expected output (with FUN_WITH_RUST=ON):
|
||||
* Hello from Rust ops!
|
||||
*
|
||||
* If built without Rust, calling rust_hello() will raise a runtime error
|
||||
* explaining that Rust integration is disabled.
|
||||
*/
|
||||
|
||||
print(rust_hello())
|
||||
|
||||
/* Expected output:
|
||||
Hello from Rust ops!
|
||||
*/
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*/
|
||||
|
||||
// Short-circuit demo for || and &&
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-12-27
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-12-27
|
||||
*/
|
||||
|
||||
print(bxor(0x80000000, 0x00000001))
|
||||
print(bor(0x80000000, 0x00000001))
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-09-30
|
||||
*/
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-09-30
|
||||
*/
|
||||
|
||||
// Threading demo for Fun
|
||||
// Run without installing:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue