Table of Contents

ANTLR

Antlr was the original parser of NCalc. While Antlr is a powerful and flexible parsing library, it is approximately 67% slower than Parlot, the default parser used by NCalc. However, this example serves to illustrate the power of DI in allowing you to easily swap out components based on your specific needs. See the source code for information in how to implement your own parser.

Installation

dotnet add package NCalc.Antlr

At your Program.cs

builder.Services.AddNCalc().WithAntlr();

After this, simply create expressions from IExpressionFactory. For more information see this article.