mirror of
https://github.com/zekexiao/pocketlang.git
synced 2025-02-05 20:26:53 +08:00
A lightweight, fast embeddable scripting language.
include | ||
src | ||
test | ||
.gitignore | ||
autotool.py | ||
LICENSE | ||
README.md | ||
SConscript | ||
SConstruct |
MiniScript Language
MiniScript is a simple embeddable, functional, dynamic-typed, bytecode-interpreted, scripting language written in C. It uses the mark-and-sweep method for garbage collection. MiniScript is is syntactically similar to Ruby. The frontend and expression parsing techniques were written using Wren Language and their wonderful book craftinginterpreters as a reference.
What MiniScript looks like
## Find and return the maximum value in the array.
def get_max(arr)
ret = arr[0]
for i in 1..arr.length
ret = max(ret, arr[i])
end
return ret
end
## Return an array where each element returns true with function [fn] and
## belongs to [arr].
def filter(arr, fn)
ret = []
for elem in arr
if fn(elem)
array_append(ret, elem)
end
end
return ret
end
array = [42, null, 3.14, "String", 0..10, [100]]
nums = filter(array, is_num)
print(get_max(nums))