Giter Site home page Giter Site logo

csharpeval's Introduction

Introduction

C# does not include a built-in method to evaluate a string during runtime, like Javascript's eval() or VBScript's Eval().

ExpressionEvaluator is a lightweight, simple and free library capable of parsing and compiling simple to medium complexity C# expressions. It features a Antlr-based tokenizer and parser and generates a LINQ Expression tree which is then compiled into a function.

Applications for an expression parser and compiler are usually in the form of embedded code or user-defined expressions that need to be executed against runtime objects.

How can I use this library?

  • An Experimental Music Compiler for Windows Mobile
  • Dynamic data-bound XML templates
  • User-defined conditional code stored in configuration files
  • Customer-defined queries
  • User-defined execution parameters for pluggable controls

If you have downloaded and used this library, I'd like to know about it's usage! Feel free to let me know about it.

NuGet

Expression Evaluator is now available via NuGet

Getting Started

See Usage and Sample Expressions under Documentation

Latest Updates

For more details see [Updates]

Features

  • Compute: Arithmetic operators: +- * / % ^
  • Compare: Relational operators: == != < > <= >=
  • Assign: Set values with the = operator
  • Test: Logical Operators: ! & | (bitwise logic) and && || (short circuit logic)
  • Expression grouping with parentheses ( )
  • Index accessors {"[ ]"}
  • Supports dynamic objects (including classes that implement IDynamicMetaObjectProvider such as ExpandoObject)
  • Context: Register and access external types and symbols through the TypeRegistry
  • Strings: (enclosed in 'single quotes' and string concatenation with +)
  • true, false, null literals
  • Declarative typing of numbers using d/f/m/l/u/ul suffixes
  • Implicit conversion of numerical expressions
  • Member access operator (.) for any valid expression. Access properties, fields and methods of types, objects and expressions
  • Pre-registered default types e.g. bool, int, double, float, char, string
  • Supports nested function calls (x.method(y.method(z.method()), y.method2()))

Donate

Expression Evaluator is 100% free, but if you would like to support the project in any way please do so.

[Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&[email protected]&lc=PH&item_name=Expression Evaluator&currency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted)

Disclaimer

This is not a fully C#-compliant compiler, and as such features may be missing and there may be bugs or discrepancies in how the parser and compiler work. If you wish to use this library in production code do so at your own risk.

csharpeval's People

Contributors

dharmatech avatar rupertavery avatar

Watchers

 avatar  avatar  avatar

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.