• Stars
    star
    125
  • Rank 285,087 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎩 MAGES is a very simple, yet powerful, expression parser and interpreter.

MAGES Logo

MAGES

GitHub CI NuGet Issues

Mages: Another Generalized Expression Simplifier

MAGES is the official successor to YAMP. It is a very simple, yet powerful, expression parser and interpreter. You can use MAGES to include a sophisticated, easy to customize, and lightweight scripting engine to your application.

Among other applications, MAGES is used in Microsoft's PowerToys.

Current Status

MAGES was just updated (v2.0.0) with support for complex numbers. Also, the build target and runtime has been updated to make use of modern possibilities.

Previous Status

The first stable version has been released. The current version 1.6.0 contains an improved REPL. The library contains everything to perform lightweight scripting operations in C#. A CodeProject article about the library (also containing some background and performance comparisons) is also available.

Installation

MAGES itself does not have any dependencies, however, the tests are dependent on NUnit and the benchmarks use BenchmarkDotNet. Usually, MAGES should be installed via the NuGet package source. If this does not work for you, then clone the source and build MAGES yourself. Make sure that all unit tests pass.

The whole library was designed to be consumed from .NET 3.5 (or higher) applications. This means it is (amongst others) compatible with Unity / Mono 2.6. The NuGet package is available via the official package feed.

Get Me Started!

In the most simple case you are creating a new engine to hold a global scope (for variables and functions) and launch the interpretation.

var engine = new Mages.Core.Engine();
var result = engine.Interpret("sin(2) * cos(pi / 4)"); // 0.642970376623918

You can also go-ahead and make reusable blocks from snippets.

var expOne = engine.Compile("exp(1)");
var result = expOne(); // 2.71828182845905

Or you can interact with elements created by MAGES.

var func = engine.Interpret("(x, y) => x * y + 3 * sqrt(x)") as Mages.Core.Function;
var result = func.Invoke(new Object[] { 4.0, 3.0 }); // 18.0

Or even simpler (details are explained in the getting started document):

var func = engine.Interpret("(x, y) => x * y + 3 * sqrt(x)") as Mages.Core.Function;
var result = func.Call(4, 3); // 18.0

These are just some of the more basic examples. More information can be found in the documentation.

Documentation

The documentation is given in form of Markdown documents being placed in the doc folder of this repository. The following links are worth checking out:

If anything is missing, unclear, or wrong then either submit a PR or file an issue. See the following section on contributions for more information.

Contributions

Contributions in form of feature implementations or bug fixes are highly welcome, but need to be performed in an organized and consistent way. The contribution guidelines should be read before starting any work.

Contributions may also be taken in form of bug reports and feature requests. Long live open-source development!

Versioning

The rules of semver are our bread and butter. In short this means:

  1. MAJOR versions at maintainers' discretion following significant changes to the codebase (e.g., breaking API changes)
  2. MINOR versions for backwards-compatible enhancements (e.g., performance improvements, additional extensions)
  3. PATCH versions for backwards-compatible bug fixes (e.g., specification compliance bugs, support issues)

Hence: Do not expect any breaking changes within the same major version.

Sponsors

The following companies sponsored part of the development of MAGES.

Thanks for all the support and trust in the project!

License

The MIT License (MIT)

Copyright (c) 2016-2022 Florian Rappl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

CmdParser

A simple and lightweight command line parser using C++11.
C++
162
star
2

Mario5TS

The TypeScript version of the Mario5 demo application.
TypeScript
60
star
3

parcel-plugin-externals

Parcel plugin for declaring externals. These externals will not be bundled. πŸ“¦
JavaScript
47
star
4

microfrontends-with-blazor-demos

Demos for my talk about "Microfrontends with Blazor". πŸš€
HTML
34
star
5

WinFormsX

Windows Forms Extensions Library for the Windows Forms applications / applications using the .NET-Framework.
C#
32
star
6

pwa-example

A short example illustrating some essential steps for creating a progressive web app (PWA).
29
star
7

kras

Efficient server proxying and mocking in Node.js. πŸ’ͺ
TypeScript
27
star
8

react-carousel-hook-example

Example for creating a carousel component based on the useCarousel hook.
TypeScript
27
star
9

react-prerender-demo

A simple demo repository to showcase how to pre-render a React application.
TypeScript
26
star
10

YAMP

Yet Another Math Parser
C#
25
star
11

dets

Generate a single declaration file for your TypeScript project. πŸš€
TypeScript
24
star
12

bundler-comparison

Comparison of web resource bundlers. πŸ“¦
TypeScript
22
star
13

JsonEditor

Simple example JSON editor powered by a JSON schema. β›„
C#
16
star
14

portal-sample

Sample React web app to host a portal for (framework independent) mini applications. πŸš€
TypeScript
15
star
15

dynamic-esm-microfrontends-demo

Demo for using ESM with dynamic imports for creating microfrontend solutions. πŸš€
TypeScript
12
star
16

typescript-fullstack-sample

A sample repository to demonstrate creating a full stack web app using TypeScript with Node.js and React.
TypeScript
11
star
17

parcel-plugin-codegen

Parcel plugin for bundle-time code generation. Simple, powerful, and flexible. πŸ“¦
JavaScript
10
star
18

react-arbiter

πŸš€ Recall all your modules to extend your SPA dynamically at runtime.
TypeScript
9
star
19

jest-fs-snapshot

Jest matcher for filesystem snapshotting.
JavaScript
7
star
20

peerjs-example-app

A small video chat solution using PeerJS as written in the LogRocket article.
TypeScript
7
star
21

tikz.js

Creates standalone graphics based on PGF/TikZ using LaTeX and ImageMagick.
JavaScript
7
star
22

Sumerics

Sumerics is a touch enabled sensor application for doing numerical calculations on Windows 8+ computers.
C#
6
star
23

ts-transform-sample

Sample code for using TypeScript transforms.
TypeScript
6
star
24

piral-webpack-tools

Integrates webpack for debugging and building pilets. πŸš€
TypeScript
6
star
25

react-concurrent-mode-example

One example where React concurrent mode excels in user experience. :atom:
JavaScript
5
star
26

ddc-sample-microfrontend-app

A sample microfrontend solution using only Blazor and ASP.NET.
C#
5
star
27

DWX-Trickbox

Demo code as shown in the talk "Another look at the C# (6.0) trickbox" at the DWX 2015.
C#
4
star
28

piral-cli-local-feed

Adds a command to run a local feed service. πŸš€
TypeScript
4
star
29

parcel-plugin-import-maps

Enables support for import-maps in Parcel. πŸ—ΊοΈ
JavaScript
4
star
30

HarmOsc

The harmonic oscillator on the lattice simulated using the HMC algorithm.
C++
4
star
31

module-federation-with-systemjs-importmap

A simple example showing how a host can dynamically introduce MFs with shared dependencies using Webpack Module Federation.
JavaScript
4
star
32

Partial.Newtonsoft.Json

Helper library to support deserializing fragments of types.
C#
3
star
33

parcel-plugin-browserconfig

A simple plugin for Parcel to traverse a browserconfig.xml file. πŸ“¦
JavaScript
3
star
34

piral-nextjs-sample

Migrating an existing Next.js application to be used in a Piral instance as a pilet. πŸ“¦
JavaScript
3
star
35

mario5-sample-pilet

A pilet running the Mario5 game for the sample-piral app shell. πŸ‘»
TypeScript
3
star
36

DevOpsLittleHelper

Azure Functions demo project for the CodeProject serverless competition.
C#
3
star
37

Piral.Blazor.Server.Samples.Tractor

Repository for the famous tractor micro frontend sample using Piral.Blazor.Server.
C#
3
star
38

volley-sample-pilet

A pilet running the Ultimate Volley game for the sample-piral app shell. 🏐
TypeScript
2
star
39

snow-pilet

A pilet to produce snow on the website
TypeScript
2
star
40

portal-sample-piral

Recreation of my portal-sample project using Piral πŸš€.
TypeScript
2
star
41

nightwatch-nunit3-reporter

An NUnit3 reporter for Nightwatch.js. πŸ’»
TypeScript
2
star
42

ts-webpack-virtual-resolve

Example of resolving virtual modules from TypeScript with Webpack.
JavaScript
1
star
43

react-workshop-2022

:atom: Material for the React workshop.
JavaScript
1
star
44

parcel-plugin-at-alias

Parcel plugin to provide support for aliases starting with '@'. πŸ“¦
JavaScript
1
star
45

tower-defense-sample-pilet

A pilet running a Tower Defense game for the sample-piral app shell. 🏠
TypeScript
1
star
46

piral-cli-dotenv

Adds a flag to include environment variables from .env files. πŸš€
TypeScript
1
star
47

Simplet

A simple C# class generator for static text templates.
C#
1
star
48

mife-tutorial

Tutorial for a minimalistic microfrontend setup using React. :atom: πŸš€
JavaScript
1
star
49

ModernCS

Examples for my presentation regarding C# for professionals
C#
1
star
50

schaaf.js

Example code for the "custom JS framework" session at My Coding Zone (5th of April 2024).
JavaScript
1
star
51

spaceshoot-sample-pilet

A pilet running the infamous SpaceShoot game for the sample-piral app shell. πŸ‘Ύ
TypeScript
1
star
52

SpiderSample

A short sample code for demonstrating some features of the Spider programming language.
JavaScript
1
star
53

ts-service-boilerplate

Example boilerplate code for writing a Node.js service in TypeScript incl. OpenAPI spec generation and unit testing.
TypeScript
1
star
54

msdevrgb-web2018-demo

Demo code derived during the talk about Web Development 2018 at the Microsoft Developer Group in Regensburg.
TypeScript
1
star
55

cz-lang

My Coding Zone stream project - create your own programming language
TypeScript
1
star
56

kras-swagger-injector

Mock web service APIs by providing Swagger YAML files. πŸ’ͺ
TypeScript
1
star
57

Chocolatey-Julia

Chocolatey package to install the Julia programming language.
PowerShell
1
star
58

FlorianRappl

My GitHub profile.
1
star
59

react-alpine

A proof of concept / idea for a JS-in-JS implementation to enable ultra-fast websites with some degree of interactivity.
TypeScript
1
star