crufter/minima
Scripting language for Go.
{ "createdAt": "2012-06-16T12:07:19Z", "defaultBranch": "master", "description": "Scripting language for Go.", "fullName": "crufter/minima", "homepage": "", "language": "Go", "name": "minima", "pushedAt": "2012-09-07T05:35:21Z", "stargazersCount": 39, "topics": [], "updatedAt": "2023-07-23T06:54:33Z", "url": "https://github.com/crufter/minima"}Minima
Section titled “Minima”Minima is an experimental interpreter written in Go (the language is called the same). We needed a way to massage our JSON data with a scripting language.
The syntax (or the lack of it) is inspired by Lisp, to be easy to parse for machines. However, I tried to get rid of the zillions of parentheses to be easy to parse for humans too. With significant whitespace and indentation, the outermost parentheses are there, but they are kinda transparent.
Everything is subject to change.
General example
Section titled “General example”-- This is a commentset n (+ 2 1)set x 8if (< n x) run println "Multiline if." println "n is smaller than " x println "n is greater or equal than " xfor n println "n is " nThis above snippet will produce:
Multiline if.n is smaller than 8n is 3n is 3n is 3Newline shorthand
Section titled “Newline shorthand”One can use the ”;” as a shorthand for a newline with same indentation:
set a 10; set b 20Function definition and call
Section titled “Function definition and call”set k 10func l (u) (run println k + u u u u)println (l 20)println uProduces:
1080<nil>Closures
Section titled “Closures”func l (u) (run set m 9 func (v) (+ v u m))set p (l 10)println (p 30)println (p 40)Produces:
4959Recursion
Section titled “Recursion”func fib (x) if (| (eq x 0) (eq x 1)) get x + (fib (- x 1)) (fib (- x 2))println (fib 15)Produces:
610Panic/recover
Section titled “Panic/recover”func k (panic "OMG")func f (run recover (run(println "Recovering from " prob) (+ 1 1)) println "Panicking in next function call." k println "This shall not run.")func l (run println "Just a casual println..." set ret (f) println "This shall run." get ret)println (l)println "Recovered"Produces:
Just a casual println...Panicking in next function call.Recovering from OMGThis shall run.2Recoveredfunc f (run defer (println 0) defer (println 1) println "This shall run before the deferred functions.")fProduces:
This shall run before the deferred functions.10- Create a language in pure Go.
- Create a scripting language which is statically typed.
Latest additions
Section titled “Latest additions”- Defer
- Panic/Recover
- Better recursion support.
- Eq, |, & operators.
- Variable scoping, functions, closures.
Roadmap
Section titled “Roadmap”- Defer
- []interface{} and map[string]interface{} types to be able to handle JSON data.
- More syntactic sugar (expect some neat things here).
- More builtin goodies.
- Static typing.
- Packages.
- A mongodb driver ;)
- Optimizations.