Skip to content

trashSydowDev/zygomys

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

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 Go structs from the scripted configuration. zygomys borrows certain constructs from Clojure, and others from Go.

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.

The standalone REPL is called simply zygo. Use make to install zygo as go get will call it zygomys by default, and the tooling expects the shorter zygo for tests, etc.)

Not your Grandfather's Parentheses... features in zygomys 1.3.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
  • JSON and Msgpack interop: serialization and deserialization.
  • (range key value hash (body)) range loops mirror for-range over a hash in Go.
  • (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

Obligatory XKCD: "elegant weapons... for a more civilized age"

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
  • An actual working 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

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

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.

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).

About

Java has Clojure, Go has Zygomys. A 100% Golang, easy-to-use Lisp.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 85.7%
  • Emacs Lisp 13.6%
  • Other 0.7%