Skip to content

common-xtext-expression-language (CXEL) is an Xtext based DSL and a java runtime engine for expressions and commonly used functions for data transformations

License

Notifications You must be signed in to change notification settings

intuit/common-xtext-expression-language

Repository files navigation

Common-Expression-Language

common-xtext-expression-language logo

The project provides an expression language built using Xtext and a runtime engine to evaluate the expressions. The expression grammar can be imported in other Xtext DSLs to create composable and reusable languages using Xtext. It can also be used to evaluate expressions independently. Currently, the runtime is in Java language but it can be updated to any other language as well.

Targeted Users

DSL Developers who need to run expressions in their DSL can import the Common-Xtext-Expression-Language and the ready-to-use runtime engine in the DSL.

Usage

  1. Add the maven dependency
  <groupId>com.intuit.dsl.expression</groupId>  
  <artifactId>com.intuit.dsl.expression.runtime</artifactId>
  <version>${latest}</version>
  1. Code usage
   DataValue value = ExpressionRuntime.newExpressionRuntime()
                           .withExpressionContent(expressionString)
                           .evaluate();

#Example

let’s say you are creating a new DSL for representing a rule engine. Something like below:

Rules myRules {
      when ${expression} then rule1
      when ${expression} then rule2
      when ${expression} then rule3
}

You can import the expression language to represent the ${expression} in your DSL and execute the available expressions from the Common-Xtext-Expression-Language.

Setting up the Project

Pre-requisites

  1. Java 8
  2. Maven 3

Making changes to Runtime

  • Clone common-xtext-expression-language
  • Run mvn clean install
  • Import the runtime module com.intuit.dsl.expression.runtime. This is standard java project which can be imported in your favorite editor.

Making changes to Expression Grammar

  1. Download and install Eclipse MAC / Windows / Linux.

  2. Install Xtext SDK in Eclipse:
    a. In Eclipse, click Help --> Install New Software.
    b. In Available Software, click Add to add a repository with the following location http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/
    c. Select the repository just added in 'Work with' dropdown.
    d. Select and install Xtext Complete SDK.

  3. Restart Eclipse.

  4. Edit the grammar

  5. Right click on GenerateExpression.mwe2. Run As --> 1 MWE2 Workflow.

    OR

    mvn clean install inside the project

You should be able to use the grammar changes in your runtime.

Formatting

Read the Contribution guide

About

common-xtext-expression-language (CXEL) is an Xtext based DSL and a java runtime engine for expressions and commonly used functions for data transformations

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages