Skip to content

UExL expression language parser for go projects!

Notifications You must be signed in to change notification settings

maniartech/uexl-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UExL (Universal Expression Language) in Golang

Introduction

UExL (Universal Expression Language) is an embeddable platform independent expression evaluation engine. It is a simple language that can be used to evaluate expressions in various formats. UExL is designed to be used in applications where the expression to be evaluated is not known at compile time. Or to make the application more flexible by allowing the user to define expressions through the configuration file or database.

, is a . Designed for efficiency and simplicity, UExL offers an intuitive approach to handling and evaluating expressions in various formats.

Table of Contents

Installation

UExL is not yet released and ready for use. However, whenever it is, you can install it using the following instructions.

Installing UExL

To install UExL, run the following command in your terminal:

go get github.com/maniartech/uexl-go

This command downloads and installs the UExL package along with its dependencies.


Getting Started

Importing the Library

First, include UExL in your Go project by importing it:

import "github.com/maniartech/uexl-go"

Basic Usage

Here’s how you can quickly start using UExL to evaluate an expression:

package main

import (
    "fmt"
    "github.com/maniartech/uexl-go"
    "log"
)

func main() {
    // Evaluating a simple expression
    result, err := uexl.Eval("10 + 20")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Result: %v\n", result) // Output: Result: 30

    // Using pipe operator in expression
    result, err = uexl.Eval("10 + 20 |: $1 * 2")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Result: %v\n", result) // Output: Result: 60
}

This basic example demonstrates how to use UExL to evaluate simple arithmetic expressions.

Features

(List the key features of UExL.)

Operator Precedence

Operators Type Associativity
( ) Parentheses Left to Right
. Dot Left to Right
% Modulus Left to Right
* / Multiplicative Left to Right
+ - Additive Left to Right
<< >> Bitwise Shift Left to Right
< > <= >= Comparison Left to Right
== != Equality Left to Right
& | ^ Bitwise Left to Right
&& || Logical Left to Right
|: Pipe Left to Right

Examples

result, err := uexl.Eval("10 + 20 |: $1 * 2") // Returns 60

About

UExL expression language parser for go projects!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published