tamarin

package module
v2.0.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 14 Imported by: 0

README

Tamarin

CircleCI MIT license Go.Dev reference Go Report Card Releases

A fast and flexible embedded scripting language for Go projects. Tamarin compiles scripts to bytecode internally which it then runs on a lightweight Tamarin Virtual Machine (VM). Tamarin is written in pure Go.

Tamarin modules integrate the Go standard library, making it easy to write scripts using functions that you're already familiar with as a Go developer.

Thanks to the new VM, Tamarin v2 is 127x faster than v1!

v2.0.0 Alpha Release

As of June 2023, the Tamarin v2.0.0 alpha release has entered the testing phase. I'm seeking community feedback before finalizing the exact language features for v2 of the language. Please share your thoughts and questions on the discussions page.

Documentation

Documentation is available at cloudcmds.github.io/tamarin.

Getting Started

The Quick Start in the documentation is where you should head to get started.

If you use Homebrew, you can install the Tamarin CLI as follows:

brew tap cloudcmds/tamarin
brew install tamarin

Having done that, just run tamarin to start the CLI or tamarin -h to see usage information.

Using Tamarin

Tamarin is designed to be versatile and accommodate a variety of usage patterns. You can leverage Tamarin in the following ways:

  • REPL: Tamarin offers a Read-Evaluate-Print-Loop (REPL) that you can use to interactively write and test scripts. This is perfect for experimentation and debugging.

  • Library: Tamarin can be imported as a library into existing Go projects. It provides a simple API for running scripts and interacting with the results, in isolated environments for sandboxing.

  • Executable script runner: Tamarin scripts can also be marked as executable, providing a simple way to leverage Tamarin in your build scripts, automation, and other tasks.

  • API: (Coming soon) A service and API will be provided for remotely executing and managing Tamarin scripts. This will allow integration into various web applications, potentially with self-hosted and a managed cloud version.

Quick Example

Here's a short example of how Tamarin feels like a hybrid of Go and Python, with new features like pipe expressions for transformations, and with access to portions of the Go standard library (like the strings package):

array := ["gophers", "are", "burrowing", "rodents"]

sentence := array | strings.join(" ") | strings.to_upper

print(sentence)

Output:

GOPHERS ARE BURROWING RODENTS

Syntax Highlighting

A Tamarin VSCode extension is already available which currently only offers syntax highlighting.

You can also make use of the Tamarin TextMate grammar.

Benchmark

Execution time in seconds for computing the 35th Fibonacci number:

Measured on a Macbook Pro 13-inch, M1, 2020

Contributing

Tamarin is intended to be a community project. You can lend a hand in various ways:

  • Please ask questions and share ideas in GitHub discussions
  • Share Tamarin on any social channels that may appreciate it
  • Open GitHub issue or a pull request for any bugs you find
  • Star the project on GitHub

Discuss the Project

Please visit the GitHub discussions page to share thoughts and questions.

Credits

Check CREDITS.md.

License

Released under the MIT License.

Copyright Curtis Myzie / github.com/myzie.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eval

func Eval(ctx context.Context, source string, options ...Option) (object.Object, error)

Types

type Option

type Option func(*Tamarin)

func WithBuiltins

func WithBuiltins(builtins map[string]object.Object) Option

func WithCode

func WithCode(c *object.Code) Option

func WithCompiler

func WithCompiler(c *compiler.Compiler) Option

func WithDefaultBuiltins

func WithDefaultBuiltins() Option

func WithDefaultModules

func WithDefaultModules() Option

func WithImporter

func WithImporter(i importer.Importer) Option

func WithInstructionOffset

func WithInstructionOffset(offset int) Option

type Tamarin

type Tamarin struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package ast defines abstract syntax tree types that represent Tamarin code.
Package ast defines abstract syntax tree types that represent Tamarin code.
Package builtins defines the default set of builtin functions for Tamarin.
Package builtins defines the default set of builtin functions for Tamarin.
cmd
tamarin-lsp
This package implements a Tamarin language server.
This package implements a Tamarin language server.
Package compiler is used to compile an Abstract Syntax Tree (AST) into its corresponding bytecode.
Package compiler is used to compile an Abstract Syntax Tree (AST) into its corresponding bytecode.
internal
arg
tmpl
Package tmpl is used to parse Tamarin string templates.
Package tmpl is used to parse Tamarin string templates.
Package lexer contains the code to lex input programs into a stream of tokens.
Package lexer contains the code to lex input programs into a stream of tokens.
modules
all
fmt
os
pgx
Package object defines the standard set of object types in Tamarin.
Package object defines the standard set of object types in Tamarin.
Package op defines the opcodes that are used in the Tamarin virtual machine.
Package op defines the opcodes that are used in the Tamarin virtual machine.
Package parser is used to parse an input program from its tokens and produce an abstract syntax tree (AST) as output.
Package parser is used to parse an input program from its tokens and produce an abstract syntax tree (AST) as output.
Package repl implements a read-eval-print-loop for Tamarin.
Package repl implements a read-eval-print-loop for Tamarin.
tests
Package token defines the tokens that are produced when lexing Tamarin code.
Package token defines the tokens that are produced when lexing Tamarin code.

Jump to

Keyboard shortcuts

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