Posts

Migrating from ANTLR2 to ANTLR4

ANTLR is a popular parser generator or “compiler-compiler”, developed by prof. Terence Parr and several contributors. It’s been around since 1992, as an evolution of PCCTS. It’s gone through multiple major versions. The latest incarnation of ANTLR is version branch 4.x, the first release of which is from 2013. Here at Strumenta, we use ANTLR4 […]

Parsing SQL

You can find the code presented in this article in the companion repository SQL is a language to handle data in a relational database. If you worked with data you have probably worked with SQL. It is in the same league of HTML: maybe you never learned it formally but you kinda know how to […]

Create a Transpiler: From VBA to VB.NET

Create a Transpiler: From VBA to VB.NET

In this tutorial we show how to create a transpiler, a software that can be useful in a few scenarios: if you have a large codebase in a language that does not fit your needs anymore, you still want to keep developing in one language, but you need better performance or need to run in […]

So Much Data, So Many Formats

So Much Data, So Many Formats: a Conversion Service

Data is a core resource for many activities. One important challenge for handling data is storing the data in the right way. We need to choose a format that makes easy solving the problem at hand. When multiple problems are being solved using the same data, that could mean that the same data has to […]

Getting started with ANTLR in C#

Getting started with ANTLR in C#

Readers of this website will know that ANTLR is a great tool to quickly create parsers and help you in working with a known language or create your DSL. While the tool itself is written in Java, it can also be used to generate parsers in several other languages, for instance Python, C# or Javascript (with […]

ANTLR Mega Tutorial

The ANTLR Mega Tutorial

Parsers are powerful tools, and using ANTLR you could write all sort of parsers, usable from many different languages. In this complete tutorial we are going to: explain the basics: what a parser is, what it can be used for see how to setup ANTLR to be used from Javascript, Python, Java and C# discuss […]

Translate JavaScript to C#

Translate Javascript to C#

Let’s say you need to automatically port some code from one language to another, how are going to do it? Is it even possible? Maybe you have already seen a conversion between similar languages, such as Java to C#. That sounds much simpler in comparison. In this article we are going to discuss some strategies […]

Code Generation with Roslyn: a Skeleton Class from UML

Code Generation with Roslyn: a Skeleton Class from UML

We have already seen some examples of transformation and analysis of C# code with Roslyn. Now we are going to see how to create a more complex example of code generation with Roslyn and parsing with Sprache. We are going to create a skeleton class from a PlantUML file. In short, we are doing the […]

Create a simple parser in C# with Sprache

Create a simple parser in C# with Sprache

Everybody loves ANTLR, but sometimes it may be overkill. On the other hand, a regular expression just doesn’t cut it or it may be too complicated to maintain. What a developer can do in such cases ? He uses Sprache. As its creators say: Sprache is a simple, lightweight library for constructing parsers directly in […]

Generate diagrams from C# source code using Roslyn

Beyond the source code Last week we have seen how to use Roslyn to rewrite source code to your liking. That’s all well and good, but it’s not the only thing you can do when you have a compiler open and ready to do your bidding. Another possibility is to leverage the knowledge that the […]