Some people have asked us how we are going to write our compiler, and if that is not very complicated.

The honest answer to that question is that it is indeed very complicated, but we use tools to help us doing it, which makes it a little bit easier.

In my previous blog article I have described how we are using the Roslyn infrastructure for a large part of our compiler, and that “all” we have to do is to create a recognizer for our language.

In this article I would like to elaborate a little bit about the language recognition part.


For our language recognition we are using a tool called ANTLR (Another Tool for Language Recognition), written by Terence Parr, a professor from the University of San Fransisco.

This tool allows us to generate a major part of the language recognizer from language definition files. This language definition roughly consist of 2 elements:

  1. Tokens. These are the sequences of characters that form the Keywords, Identifiers, Constants (Strings, Integers, Floats, Symbols etc.) comments and whitespace in our language.
  2. Rules. These are the sequences of tokens that form our language.

From this definition the Antlr tool generates classes:

  1. A Lexer class that scans the source code and builds a list of tokens (the tokenstream)
  2. A Parser class that uses the rules and scans for the patterns from the language elements. This builds the Parse Tree.

Read more: Creating a language definition for a compiler

Comments (0 Comments)

Some people have asked us if we have lost our mind. And that is a very good question:

What they mean is that writing a compiler from scratch is a hell of a job and will take a lot of time.

But we are not writing a compiler from scratch

So we have NOT lost our mind. Let me explain that a little bit:

Early 2015 Microsoft has published the source code for its C# and VB compiler. This is called the Roslyn Project.

You can find this on the web on and

Since this source code is licensed under the Apache 2.0 Open Source license we can use and change this code to create our X# compiler.

That means the the biggest part of the code in our compiler has been developed by the geniuses at Microsoft and has been tested by hundreds of thousands of developers all over the world. That is a HUGE benefit for our project.

So it is easy then?

No it is still not easy to write the compiler but a lot of work has already been done.

The following image displays a compiler in a schematic way:


compiler pipeline

Read more: Have we lost our mind?

Comments (0 Comments)

On this Blog page the members of the XSharp devteam will tell about the current progress in the development of XSharp and inform you about the challenges they are facing

Comments (0 Comments)