GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - codingseb/ExpressionEvaluator: A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts

BranchesTags
Open more actions menu

Latest commit

 

History

685 Commits
685 Commits

Folders and files

NameName
Last commit message
Last commit date
CodingSeb.ExpressionEvaluator.Tests
CodingSeb.ExpressionEvaluator.Tests
 
 
CodingSeb.ExpressionEvaluator
CodingSeb.ExpressionEvaluator
 
 
TryWindow
TryWindow
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CodingSeb.ExpressionEvaluator.sln
CodingSeb.ExpressionEvaluator.sln
 
 
Icon.png
Icon.png
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 

Repository files navigation

ExpressionEvaluator Icon

ExpressionEvaluator

⚠️ For now, I don't have time to maintain this repository. So if you have PR to fix some bugs. I'll be happy to review and merge it. Otherwise, I will no longer actively develop ExpressionEvaluator. If the current state of the lib do not suite your needs I suggest you look the list of great alternative projects below.

A Simple Math and Pseudo C# Expression Evaluator in One C# File.

And from version 1.2.0 can execute small C# like scripts

It is largely based on and inspired by the following resources this post on stackoverflow, NCalc, C# Operators and C# Statement Keywords

Status

Branch Status
master Build Status
dev Dev Status
nuget NuGet Status

Features

  • Basic mathematical and logical expression evaluation
  • System.Math methods and constants directly available (some like Max, Min, Avg are improved)
  • Some useful functions for example to create List and Arrays
  • Custom variables definition
  • On the fly variables and functions evaluation (To easily extend possibilities, Manage also on instance Property and Methods)
  • A large set of C# operators availables
  • Instance and static methods and properties access like as in C#
  • You can call Methods and/or Properties on your own classes (just pass a object as custom variables)
  • C# primary types
  • Use strings as in C# (@"", $"", $@"" available)
  • Lambda expressions
  • Classes like File, Directory, Regex, List ... available (You can extend the list of Namespaces)
  • Create instance with new(MyClassName, constructorArgs) or new MyClassName(constructorArgs)
  • Call void methods with fluid prefix convention to chain operations
  • Manage ExpandoObject
  • Create custom Operators or change the parsing process

And with ScriptEvaluate method

  • Small C# like script evaluation (Multi expressions separated by ; )
  • Some conditional and loop blocks keywords (if, while, for, foreach ...)
  • Multi-line (multi expression) Lambda expressions. (Can be use as method See #72 Declare methods in scripts and the doc)

Resources

  • Getting Started
  • Documentation on the wiki
  • Live Demos
  • Try it

Similar projects

Free

  • NCalc
  • Jint Support scripting but with Javascript
  • NLua use Lua language in C#
  • MoonSharp
  • DynamicExpresso
  • Flee
  • Jace.Net
  • Calculator
  • Westwind.Scripting
  • CS-Script Best alternative (I use it some times) -> Real C# scripts better than ExpressionEvaluator (But everything is compiled. Read the doc. Execution is faster but compilation can make it very slow. And if not done the right way, it can lead to memory leaks)
  • Roslyn The Microsoft official solution (For scripting see)
  • MathParser expression tree compiler and interpreter for math expressions. Heavily inspired by Roslyn.
  • YoowzxCalc
  • Scriban
  • WattleScript
  • AngouriMath For advanced Math in C#
  • Fluid
  • ClearScript
  • Expressive
  • IronPython to execute python in .Net or .Net in python

Commercial

  • Eval Expression.NET
  • mXparser (dual licensing) (Free for open source)

Projects that could help you build your own expression/script evaluator

  • SuperPower
  • Sprache
  • CSLY : C# lex and yacc
  • Lexepars
  • Parlot
  • Irony
  • Pidgin

Reading and resources

  • Crafting interpreters
  • Building a compiler An excellent Youtube tutorial
  • Search for LEX, YACC, AST, Syntaxic trees...

I would say every C# evaluation libraries have drawbacks and benefits, ExpressionEvaluator is not an exception so choose wisely (Read docs and licences).

The biggest difference of ExpressionEvaluator is that everything is evaluated on the fly, nothing is compiled or transpile nor in CLR/JIT/IL nor in lambda expressions nor in javascript or other languages stuffs. So it can be slower in some cases (sometimes not) but it also avoid a lot of memory leaks. It is clearly not optimized for big reuse of expressions as the expression is reevaluated every time (Filtering on big dataset for example). It already allow to evaluate some small scripts. If you don't want an another .dll file in your project, you only need to copy one C# file in your project. And it's MIT licence

Donate

Expression Evaluator is free and will always be.
But if you want to say thanks for this lib with a donation or small sponsoring here you can :
Donate

Thank you anyway for using ExpressionEvaluator

About

A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts

Topics

calculationscsharp-scriptevalevaluateevaluate-expressionsevaluationevaluatorexecuteexecutescriptexpressionexpression-evaluatorexpression-parserfluidmathmathematical-expressionsmathematical-expressions-evaluatorparserreflectionscriptscripting

Resources

Readme
MIT license
Activity

Stars

631 stars

Watchers

30 watching

Forks

101 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.