manyworlds

module
v1.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2016 License: BSD-2-Clause

README

Image of Gopher flying

zygomys - embedded scripting language for Go.

quickly create a mini-language to configure your project

zygomys is an embeddable scripting language. It is a Lisp, and provides an interpreter and REPL (Read-Eval-Print-Loop; that is, it comes with a command line interactive interface).

where did the name zygomys come from?

zygomys is a contraction of Zygogeomys, a genus of pocket gophers. The Michoacan pocket gopher (Zygogeomys trichopus) finds its natural habitat in high-altitude forests.

The term is also descriptive. The stem zygo comes from the Greek for yoke, indicating a pair or a union of two things, and mys comes from the Greek for mouse. The union of Go and Lisp in a small cute package, that is zygomys.

tell me more

zygomys allows you to create a Domain Specific Language to drive your program with minimal fuss and maximum convenience.

It is written in Go and plays easily with Go programs and Go structs, using reflection to instantiate trees of Go structs from the scripted configuration. These data structures are native Go, and Go methods will run on them at compiled-Go speed.

Because it speaks JSON and Msgpack fluently, zygomys is ideally suited for driving complex configurations and providing projects with a domain specific language customized to your challenges and driving other code.

The example snippets in the tests/*.zy provide many examples. The full documentation can be found in the Wiki. zygomys blends traditional and new. While the s-expression syntax defines a Lisp, zygomys borrows some syntax from Clojure, and some (notably the for-loop style) directly from the Go/C tradition.

The standalone REPL is called simply zygo.

installation
$ go get github.com/glycerine/zygomys/cmd/zygo
Not your Grandfather's Parentheses... features in zygomys 1.5.9 include
  • Use zygo to configure trees of Go structs, and then run methods on them at natively-compiled speed (since you are calling into Go code).
  • emacs/zygo.el emacs mode
  • command line editing (courtesy of https://github.com/peterh/liner)
  • JSON and Msgpack interop: serialization and deserialization.
  • (range key value hash_or_array (body)) range loops act like Go for-range loops: iterate through hashes or arrays.
  • (for [(initializer) (test) (advance)] (body)) for-loops match those in C and Go. Both (break) and (continue) are available for additional loop control.
  • Raw bytes type (raw string) lets you do zero-copy []byte manipulation.
  • Record definitions (defmap) make configuration a breeze.
  • Files can be recursively sourced with (req path) or (source "path-string").
  • Go style raw string literals, using `backticks`, can contain newlines and " double quotes directly. Easy templating.
  • Easy to extend. See the repl/random.go, repl/regexp.go, and repl/time.go files for examples.
  • Clojure like threading (-> hash field1: field2:) and (:field hash) selection.
  • Macros for your DSL. Syntax-quote templates work anywhere; inside lists, [] arrays and {} hashes.
Obligatory XKCD

Additional features
  • zygomys is a small Go library, easy to integrate and use/extend.
  • Float, Int, Char, String, Symbol, List, Array, and Hash datatypes builtin.
  • Arithmetic (+, -, *, /, mod, **)
  • Shift Operators (sll, srl, sra)
  • Bitwise operations (bit-and, bit-or, bit-xor)
  • Comparison operations (<, >, <=, >=, ==, !=, and not=)
  • Short-circuit boolean operators (and and or)
  • Conditionals (cond)
  • Lambdas (fn)
  • Bindings (def, defn, and let)
  • Standalone and embedable REPL.
  • Tail-call optimization
  • Go API
  • Macro System with macexpand (macexpand (your-macro)) makes writing/debugging macros easy.
  • Syntax quoting -- with caret ^() instead of backtick.
  • Channel and goroutine support
  • Pre- and Post- function call hooks
  • Lexical scope.

See the wiki for lots of details and a full description of the zygomys language..

License

Two-clause BSD, see LICENSE file.

Author

Jason E. Aten, Ph.D.

Credits

The ancestor dialect, Glisp, was designed and implemented by Howard Mao.

The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/) The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details: https://blog.golang.org/gopher

XKCD https://xkcd.com/297/ licensed under a Creative Commons Attribution-NonCommercial 2.5 License(https://xkcd.com/license.html).

Directories

Path Synopsis
cmd
zygo
The zygomys command line REPL is known as `zygo`.
The zygomys command line REPL is known as `zygo`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL