gonulang
v0.1.0
Published
A small embeddable scripting language with functions, closures, and arrays
Downloads
18
Maintainers
Readme
Gonu
A small, embeddable scripting language with functions, closures, and arrays.
fun greet(name) {
print "Hello, " + name + "!"
}
greet("Ada")Install
npm install gonuCLI usage
gonu examples/hello.myEmbed in your app
const { run } = require("gonu");
const output = [];
run(`
fun square(n) { return n * n }
print square(12)
`, {
print: (line) => output.push(line),
});
console.log(output); // ["144"]Language features
- Functions with closures and recursion
- Arrays, indexing,
for…in if/else if/elsewhileandforloops withbreak/continue- Strings, numbers, booleans,
null - Builtins:
len,push,pop,range,str,int,num,type - Safety: no
eval, step limit, memory cap
API
run(source, options)
source— string of Gonu codeoptions.print— called with each line of output (default:console.log)options.input— called when the program callsinput()options.maxSteps— execution step limit (default: 100000)options.maxArrayLen— array size limit (default: 100000)
Returns { vars, steps }.
License
MIT
