Nccc 1.0.0

.NET Standard 2.0
Install-Package Nccc -Version 1.0.0
dotnet add package Nccc --version 1.0.0
<PackageReference Include="Nccc" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nccc --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Nccc, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Nccc as a Cake Addin
#addin nuget:?package=Nccc&version=1.0.0

// Install Nccc as a Cake Tool
#tool nuget:?package=Nccc&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


.Net Compiler Compiler Combinator

Make Making Parser Easy


Parsec的意思是Parser Combinators。其思想是基于一些基础parser,使用parser组合子组合成复杂的parser。

这些基础parser都是一些简单的parser,简单到非常容易编程实现。 比如匹配字符串A的parser(记为'A'),匹配一个数字的parser(记为<number>)等。

Parser组合子类似正则表达式中的操作符。 比如将parser串成序列的序列操作@..,或操作@or,星号操作(零个或多个)@*


  • (@.. 'A' 'B')匹配字符串A和字符串B序列。如A B
  • (@or 'A' 'B')匹配字符串A或字符串B
  • (@? 'A')匹配空或者字符串A
  • (@* 'A')匹配零个或多个A。如AA A A A
  • (@* (@or 'A' 'B'))匹配由'A'和'B'组成的序列。如B BA AA BA B A A
  • (@or 'A' <number>)匹配由'A'或者一个数字。如A1.1
  • (@* (@or 'A' <number>))匹配由'A'和数字组成的序列。如A A1.1 2A 23A 1.2 A A

一个例子: 算术表达式


; 定义add为root parser,即最后得到的parser
:: add

; 设置参数
@set-delims '(' ')' '[' ']' '{' '}' '+' '-' '*' '/' '^'

; 下面开始组合

add = (@or add:(mul '+' add)
           sub:(mul'-' add)

mul = (@or mul:(pow '*' mul)
           div:(pow '/' mul)

pow = (@or pow:(primary '^' pow)

primary = (@or par:('(' add ')')
               par:('[' add ']')
               par:('{' add '}')
               neg:('-' pow)


private NcParser _parser = NcParser.LoadFromAssembly(Assembly.GetExecutingAssembly(), "Nccc.Tests.Calculator.calculator.grammer");


var pr = _parser.ScanAndParse("(5.1+2)*3+-2^3^2");


(((parser add))
 (success? True)
       (num[(1,2)-(1,5)] 5.1)
       (num[(1,6)-(1,7)] 2)))
     (num[(1,9)-(1,10)] 3))
      (num[(1,12)-(1,13)] 2)
       (num[(1,14)-(1,15)] 3)
       (num[(1,16)-(1,17)] 2)))))))



Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 373 11/28/2019
0.6.0 364 8/8/2019
0.5.0 346 8/8/2019
0.4.0 388 6/28/2019
0.3.0 481 12/29/2018