Using ANTLR to parse and calculate expressions (Part I)

In an upcoming series of blog posts, we are going to talk about how we have developed and integrated a simple Domain Specific Language using ANTLR4 with some of our Visual Studio projects on .NET and C#. We will also show how we’ve used the generated code to evaluate expressions at runtime for various mathematical calculations. In this first entry, we’ll discuss the initial steps, such as creating a grammar, visualizing the parsed expression tree and moving on to code generation as well as its inclusion in the .NET projects. We’ll take advantage of some of the features in the new C# project structure (csproj) that comes with Visual Studio 2017 to ensure that the latest version of our grammar is always parsed, the code generated and included in our project structure. In later posts, we’ll see how we can stream updates to a client, whenever a component’s value is updated. Using EventStore and Reactive Extensions we can make it a push based model. But more on that later. For the uninitiated ANTLR or “ANother Tool for Language Recognition” can be used (among other things) to build languages. More info on the ANTLR4 official website. The Grammar The first step… continue reading

Continue reading Using ANTLR to parse and calculate expressions (Part I). This article appeared first on CTRM Center.

Source: CTRM Center

Related Posts

Leave a reply