Git Product home page Git Product logo

talang's Introduction

Travis Codecov GoDoc go-report

Talang

Talang is a custom programming language, specifically a lisp-dialect, implemented in Go, that we developed and use internally at Talon.One.

Motivation

The motivation behind developing our own custom language is that the very nature of what our customers are doing in the core of our product is a form of programming. We needed a language to represent these "programs" with certain characteristics:

  • Easy to parse, interpret and manipulate
  • Easy to represent in JSON
  • Safe runtime properties (Talang has no recursion, no infinite loops)
  • Type-safe expressions

No existing language would fit these requirements and was also easy to integrate.

How do we use Talang at Talon.One?

Within our product, we let our customers write their own sets of what we call "Rules". These are concluded of two main types of expressions:

  • Conditions: representing predicates which evaluate to a boolean reault
  • Effects: representing expressions which return side effects handled by the promotions

We needed a way to give our customers the flexibility and control when composing such "Rules".

At the core of our product we developed a processing engine which takes these predefined Rules, gives them an execution context, and evaluates them. The return result(s) from this engine then returned to our customers to process / work with.

Why would you need it?

Talang is a very simple, fast and flexible language which is very easy to represents in JSON objects. When you desire a language, customizable, expandable, with no compiling time and fast evaluation time - Talang can be a very good choice for your requirements.

Usage

Get the package:

$ go get github.com/talon-one/talang

Then import it and use the Interpreter:

interp := talang.MustNewInterpreter()
result, err := interp.LexAndEvaluate(`(+ 1 2)`)
if err != nil {
	panic(err)
}
fmt.Println(result.Stringify()) // 3

You can refer to the examples folder for more examples and usages.

Here you can see a list of the embedded function in the language.

Playing Around

Check out our brand new playground at https://talang-land.talon.one/.

Or alternatively, get our CLI locally and play with Talang in your consolse!

Contributing

We have collected notes on how to contribute to this project in CONTRIBUTING.md.

License

Talang is released under the MIT License.

talang's People

Contributors

altjake avatar mindreframer avatar refs avatar rutaka-n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

icodein refs takng

talang's Issues

[WIP] Support ErrorStack

Each Error should contain an ErrorStack of the collected Errors

See also: interpreter.go, testhelpers/helpers.go

github.com/talon-one/talang/lexer is a parser

The package github.com/talon-one/lexer is a parser, and there is parsing related code in github.com/talon-one/token. I think that clarifying the grammar and making a single package for parsing would be beneficial. So far I think the grammar is something like:

expression = callBody | parCall | value.
parCall = "(" callBody ")".
callBody = word {arg}.
arg = word | value | parCall.
value = string | decimal | time | boolean.

With word, string, decimal, time and boolean being terminal symbols.

Also https://github.com/talon-one/talang/tree/master/docs suggests that "Mon Jan 2 15:04:05 MST 2006" is a valid time, while

b.Time, err = time.Parse(time.RFC3339, text)
assumes that the correct format is time.RFC3339. I think the assumption is right since the former format has spaces and that makes it harder to parse in this context, but the documentation is confusing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.