All Projects → tupac-amaru → Yacep

tupac-amaru / Yacep

Licence: mit
yet another csharp expression parser

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Yacep

Modern.forms
Cross-platform spiritual successor to Winforms for .NET Core
Stars: ✭ 323 (+201.87%)
Mutual labels:  cross-platform, dotnet-core
Pidgin
C#'s fastest parser combinator library
Stars: ✭ 469 (+338.32%)
Mutual labels:  parsing, dotnet-core
Estree
The ESTree Spec
Stars: ✭ 3,867 (+3514.02%)
Mutual labels:  ast, parsing
inmemantlr
ANTLR as a libray for JVM based languages
Stars: ✭ 87 (-18.69%)
Mutual labels:  parsing, ast
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+624.3%)
Mutual labels:  cross-platform, dotnet-core
Fusillade
An opinionated HTTP library for Mobile Development
Stars: ✭ 269 (+151.4%)
Mutual labels:  cross-platform, dotnet-core
Opentabletdriver
Open source, cross-platform, user-mode tablet driver
Stars: ✭ 424 (+296.26%)
Mutual labels:  cross-platform, dotnet-core
kataw
An 100% spec compliant ES2022 JavaScript toolchain
Stars: ✭ 303 (+183.18%)
Mutual labels:  parsing, ast
Esprima
ECMAScript parsing infrastructure for multipurpose analysis
Stars: ✭ 6,391 (+5872.9%)
Mutual labels:  ast, parsing
Meriyah
A 100% compliant, self-hosted javascript parser - https://meriyah.github.io/meriyah
Stars: ✭ 690 (+544.86%)
Mutual labels:  ast, parsing
hxjsonast
Parse JSON into position-aware AST with Haxe!
Stars: ✭ 28 (-73.83%)
Mutual labels:  parsing, ast
Libdparse
Library for lexing and parsing D source code
Stars: ✭ 91 (-14.95%)
Mutual labels:  ast, parsing
node-typescript-parser
Parser for typescript (and javascript) files, that compiles those files and generates a human understandable AST.
Stars: ✭ 121 (+13.08%)
Mutual labels:  parsing, ast
Simplcommerce
A simple, cross platform, modularized ecommerce system built on .NET Core
Stars: ✭ 3,474 (+3146.73%)
Mutual labels:  cross-platform, dotnet-core
kolasu
Kotlin Language Support – AST Library
Stars: ✭ 45 (-57.94%)
Mutual labels:  parsing, ast
Altcover
Cross-platform coverage gathering and processing tool set for .net/.net core and Mono
Stars: ✭ 344 (+221.5%)
Mutual labels:  cross-platform, dotnet-core
tree-hugger
A light-weight, extendable, high level, universal code parser built on top of tree-sitter
Stars: ✭ 96 (-10.28%)
Mutual labels:  parsing, ast
cppcombinator
parser combinator and AST generator in c++17
Stars: ✭ 20 (-81.31%)
Mutual labels:  parsing, ast
Firely Net Sdk
The official Firely .NET SDK for HL7 FHIR
Stars: ✭ 560 (+423.36%)
Mutual labels:  parsing, dotnet-core
Uaiso
A multi-language parsing infrastructure with an unified AST
Stars: ✭ 86 (-19.63%)
Mutual labels:  ast, parsing

link:README-en_US.adoc[English (United States)] | 中文

YACEP : yet another csharp expression parser

image:https://dev.azure.com/tupac-amaru/yacep/_apis/build/status/tupac-amaru.yacep?branchName=master["Build Status", link="https://dev.azure.com/tupac-amaru/yacep/_build/latest?definitionId=5&branchName=master"] image:https://img.shields.io/azure-devops/coverage/tupac-amaru/yacep/5.svg?label=azure%20pipelines%20coverage&color=#49bb1e[Azure DevOps coverage, link="https://dev.azure.com/tupac-amaru/yacep/_build/latest?definitionId=5&branchName=master"] image:https://codecov.io/gh/tupac-amaru/yacep/branch/master/graph/badge.svg["Build Status", link="https://codecov.io/gh/tupac-amaru/yacep"] image:https://travis-ci.com/tupac-amaru/yacep.svg?branch=master["Build Status", link="https://travis-ci.com/tupac-amaru/yacep"] image:https://img.shields.io/appveyor/ci/wushilong/yacep.svg?color=#49bb1e[AppVeyor, link="https://ci.appveyor.com/project/wushilong/yacep/branch/master"] image:https://img.shields.io/sonar/https/sonarcloud.io/tupac-amaru_yacep/quality_gate.svg?color=#49bb1e[Sonar Quality Gate, link="https://sonarcloud.io/dashboard?id=tupac-amaru_yacep"] image:https://img.shields.io/appveyor/tests/wushilong/yacep.svg?color=#49bb1e[AppVeyor tests, link="https://ci.appveyor.com/project/wushilong/yacep/branch/master"] image:https://img.shields.io/nuget/v/TupacAmaru.Yacep.svg?color=#49bb1e[Nuget, link="https://www.nuget.org/packages/TupacAmaru.Yacep"] image:https://img.shields.io/github/license/tupac-amaru/yacep.svg?color=#49bb1e["License",link="https://opensource.org/licenses/MIT"]

https://github.com/tupac-amaru/yacep/wiki[文档]

https://github.com/tupac-amaru/yacep/tree/_benchmark[基准测试报告]

简介

YACEP 是一个轻量级的表达式解析库。 能够将一段有效的字符串并转换成一棵抽象语法树. 同时具备把抽象语法树转换成一段可以执行的代码的能力。

[IMPORTANT] YACEP 不支持多行表达式,以后也不会支持. 如果需要多行表达式,个人推荐使用 https://github.com/IronLanguages[IronLanguages]

示例代码

[source,csharp]

"x+', '+y".Compile().EvaluateAs(new { x = "hello", y = "world" }); // value is "hello, world" "x + y".Compile().EvaluateAs(new { x = 1, y = 2 }); // value is 3

var state = new { x = 7, y = 43.0f, z = new Dictionary<string, string> { ["yacep"] = "yet another csharp expression parser", ["tupac-amaru"] = "was the last indigenous monarch (Sapa Inca) of the Neo-Inca State" }, rand = new Func(() => new Random().Next(1, 3)), array = Enumerable.Range(1971, 1996 - 1971) }; var expr = "x + y - z['yacep'].Length + max([1, 2, 3]) + (this.rand() > 2 ? 1971 : 1996) - len(array)"; var evaluator = expr.Compile(); var value = evaluator.EvaluateAs(state);

为什么会写这样一个库?

特性

快速上手

https://github.com/tupac-amaru/yacep/wiki[文档]

  • 创建一个控制台项目 [source,shell]

mkdir yacep-demo cd yacep-demo dotnet new console

  • 添加依赖TupacAmaru.Yacep [source,shell]

dotnet add package TupacAmaru.Yacep

  • 修改Program.cs的内容 [source,shell]

cat>Program.cs<<EOF using TupacAmaru.Yacep.Extensions;

namespace yacep_demo { class Program { static void Main() => System.Console.WriteLine("x+', '+y".Compile().EvaluateAs(new { x = "hello", y = "world" })); } } EOF

如果是windows系统,请复制以下内容到Program.cs中

[source,csharp]

using TupacAmaru.Yacep.Extensions;

namespace yacep_demo { class Program { static void Main() => System.Console.WriteLine("x+', '+y".Compile().EvaluateAs(new { x = "hello", y = "world" })); } }

  • 运行项目 [source,shell]

dotnet run

看到输出 hello, world 就说明已经成功了

鸣谢

工具&库

服务

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].