All Projects → camunda → Feel Scala

camunda / Feel Scala

Licence: apache-2.0
FEEL parser and interpreter written in Scala

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Feel Scala

Androrat
A Simple android remote administration tool using sockets. It uses java on the client side and python on the server side
Stars: ✭ 187 (+259.62%)
Mutual labels:  hacktoberfest, interpreter
Boa
Boa is an embeddable and experimental Javascript engine written in Rust. Currently, it has support for some of the language.
Stars: ✭ 2,509 (+4725%)
Mutual labels:  hacktoberfest, interpreter
Nf Interpreter
⚙️ nanoFramework Interpreter, CLR, HAL, PAL and reference target boards
Stars: ✭ 168 (+223.08%)
Mutual labels:  hacktoberfest, interpreter
Gwion
🎵 strongly-timed musical programming language
Stars: ✭ 235 (+351.92%)
Mutual labels:  hacktoberfest, interpreter
Mond
A scripting language for .NET Core
Stars: ✭ 237 (+355.77%)
Mutual labels:  hacktoberfest, interpreter
Awesome Graal
A curated list of awesome resources for Graal, GraalVM, Truffle and related topics
Stars: ✭ 302 (+480.77%)
Mutual labels:  hacktoberfest, interpreter
Openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,802 (+5288.46%)
Mutual labels:  hacktoberfest, interpreter
05ab1e
A concise stack-based golfing language
Stars: ✭ 583 (+1021.15%)
Mutual labels:  hacktoberfest, interpreter
Awesome Android Kotlin Apps
👓 A curated list of awesome android kotlin apps by open-source contributors.
Stars: ✭ 1,058 (+1934.62%)
Mutual labels:  hacktoberfest
Javascript Notes
Notes taken during Wes Bos' BeginnerJavaScript course
Stars: ✭ 52 (+0%)
Mutual labels:  hacktoberfest
Gau
Fetch known URLs from AlienVault's Open Threat Exchange, the Wayback Machine, and Common Crawl.
Stars: ✭ 1,060 (+1938.46%)
Mutual labels:  hacktoberfest
React Tracking
🎯 Declarative tracking for React apps.
Stars: ✭ 1,062 (+1942.31%)
Mutual labels:  hacktoberfest
Awesome Actions On Google
A collection of useful things regarding Actions on Google.
Stars: ✭ 52 (+0%)
Mutual labels:  hacktoberfest
Wasmjit
Small Embeddable WebAssembly Runtime
Stars: ✭ 1,063 (+1944.23%)
Mutual labels:  interpreter
Umbraco Graphql
An implementation of GraphQL for Umbraco 8 using GraphQL for .NET.
Stars: ✭ 52 (+0%)
Mutual labels:  hacktoberfest
Emotecollector
Collects emotes from other servers for use by people who don't have Nitro
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Js Api Client
Typeform API js client
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Rets
A thin RETS client
Stars: ✭ 52 (+0%)
Mutual labels:  hacktoberfest
Slack Emoji Meister
You can easily add slack emoji
Stars: ✭ 52 (+0%)
Mutual labels:  hacktoberfest
Mezzio Swoole
Swoole support for Mezzio
Stars: ✭ 52 (+0%)
Mutual labels:  hacktoberfest

FEEL Scala

Maven Central

A parser and interpreter for FEEL that is written in Scala (see What is FEEL?).

The FEEL engine started as a slack time project, grown to a community-driven project and is now officially maintained by Camunda 🚀

It is integrated in the following projects:

Features:

  • full support for unary-tests and expressions (DMN 1.2)
  • including built-in functions
  • extensible by own functions and custom object mappers

Usage

The documentation describes the supported FEEL expressions (e.g. data types, language constructs, builtin-functions, etc.), how to extend/customize the engine and contains some examples.

Install

The FEEL engine can be integrated in two different ways

Add the engine as dependency to your project's pom.xml:

<dependency>
  <groupId>org.camunda.feel</groupId>
  <artifactId>feel-engine</artifactId>
  <version>${VERSION}</version>
</dependency>

Or, download the JAR file (feel-engine-${VERSION}-complete.jar) and copy it into your application.

For trying out FEEL expression quickly in development, have a look at the FEEL REPL.

As Native Scala Application

Create a new instance of the class 'FeelEngine'. Use this instance to parse and evaluate a given expression or unary tests.

Using Scala:

object MyProgram {
  
  val engine = new FeelEngine
  
  def feel(expression: String, context: Map[String, Any]) {
    
    val result: Either[Failure, Boolean] = engine.evalSimpleUnaryTests(expression, context)
    // or    
    val result: Either[Failure, Any] = engine.evalExpression(expression, context)
  
    // handle result
    result
        .right.map(value => println(s"result is: $value"))
        .left.map(failure => println(s"failure: $failure"))
  }  
}

Or using Java:

 public class MyProgram {

    public static void main(String[] args) {

        final FeelEngine engine = new FeelEngine.Builder()
            .valueMapper(SpiServiceLoader.loadValueMapper())
            .functionProvider(SpiServiceLoader.loadFunctionProvider())
            .build();

        final Map<String, Object> variables = Collections.singletonMap("x", 21);
        final Either<FeelEngine.Failure, Object> result = engine.evalExpression(expression, variables);

        if (result.isRight()) {
            final Object value = result.right().get();
            System.out.println("result is " + value);
        } else {
            final FeelEngine.Failure failure = result.left().get();
            throw new RuntimeException(failure.message());
        }
    }
}

Enable FEEL External-Functions in the configuration:

new FeelEngine(configuration = Configuration(externalFunctionsEnabled = true))
// or
new FeelEngine.Builder().enableExternalFunctions(true).build()

⚠️ Enabling external functions is not recommended because external functions make it possible to call arbitrary Java methods. This poses a potential security risk. Enabling this feature can be safe if you have full control of the expressions that will be evaluated (i.e. none of them are entered by a user or generated by an external system). In all other cases this feature is considered unsafe. It is recommended to use the Function Provider SPI instead.

As Script Engine

Call the engine via Java's script engine API (JSR 223).

object MyProgram {

  val scriptEngineManager = new ScriptEngineManager
 
  def feel(script: String, context: ScriptContext) {
  
    val scriptEngine: FeelScriptEngine = scriptEngineManager.getEngineByName("feel")
    
    val result: Object = scriptEngine.eval(script, context)
    // ...
  }

}

The engine is registered under the names:

  • feel
  • http://www.omg.org/spec/FEEL/20140401 (qualified name)
  • feel-scala

You can also evaluate unary tests instead of an expression by using one of the names:

  • feel-unary-tests
  • feel-scala-unary-tests

FEEL REPL

The easiest way to try out your FEEL expressions in development is to use the REPL (Read-Eval-Print-Loop) of the FEEL engine. It is a simple script based on Ammonite that downloads the dependency to the FEEL engine and initialize it for you.

  1. Download Ammonite: http://ammonite.io/#Ammonite-REPL
  2. Download the script: feel-repl.sc
  3. Run the script: amm --predef feel-repl.sc

the-feel-repl

Contribution

See the Contribution Guide.

The following resources can help to understand the general concepts behind the implementation:

License

Apache License, Version 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].