Coder Social home page Coder Social logo

exprengine's Introduction

Expression Engine Library 0.6.1.1 alfa.

This project is a simple mathematical expression parser written in C#. It's the refactoring of an old project and uses an AST-evaluation algorithm. You can use built-in or add your functions and variables to global scope. It was written primarily for fun and and as programming exercise; anyway if you anyone find it useful, please send feature requests or issues; but please take note that this is still a work in progress.

At the moment specification is just a draft.

To build:

MonoDevelop or Visual Studio.

At glance:

var contex = new Context()
  .SetVariable("G", 6.67428D)
  .SetVariable("earth_mass", Evaluate.As<double>("5.97219 * pow(10,24)")) // 5.97219E+24 kg
  .SetVariable("lunar_mass", Evaluate.As<double>("7.34767309 * pow(10,22)")) // 7.34767309E+22 kg
  .SetVariable("perigee_dist", 356700000D) // moon-earth distance at perigee in m
  .SetFunction("calc_force", (object[] args) => ((double) args[0] * (double) args[1]) / Math.Pow((double) args[2], 2));
var result = contex.EvaluateAs<double>("G * calc_force(earth_mass, lunar_mass, perigee_dist)"); // 2.3018745174107073E+31
bool isGCorrect = contex.EvaluateAs<bool>("G == 6.67428");

Resources:

News:

  • String literals fully implemented.
  • Version policy changed.
  • First changes to lexer for handle string literals.
  • Refactoring, ExpressionEvaluator splitted in Context (as the name, evaluation with context) and Evaluator (static helper, contextless evaluation).
  • Added support for exponent in numeric literal ([E|e][+|-][DIGIT]).
  • Parser class aligned to new grammar.
  • BNF grammar changed (see Evaluator.grm).
  • Operator ^ (exponent) removed. Will be used as bitwise operator.
  • Introduced relational operators (==, !=, <, >, <=, >=).
  • Introduced true and false literals.
  • Heavy internal refactoring toward a new design.
  • Evaluation provided via both instance and static methods.

Contacts:

Giacomo Stelluti Scala

exprengine's People

Contributors

gsscoder avatar

Watchers

James Cloos avatar Allen 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.