Florian Rappl

Building a Compiler with C#

Your IDE's refactoring tools are powered by a compiler. We'll build a simple one in C# to see exactly how it's done.

Building a Compiler with C#
#1about 4 minutes

Understanding the Roslyn compiler platform for C#

Roslyn is more than a black-box compiler, providing rich language service APIs that power IDE features like refactoring and code analysis.

#2about 2 minutes

Exploring C# code with Roslyn and LINQPad

Use a tool like LINQPad to see how Roslyn transforms C# source code into intermediate language (IL) and visualizes it as a syntax tree.

#3about 4 minutes

The motivation for building a custom language

A custom, high-performance language was needed to power a game that dynamically generates worlds from user-defined mathematical formulas.

#4about 3 minutes

Defining a language with a formal grammar

Creating a new language starts with a formal specification or grammar that defines its syntax using symbols and rules.

#5about 3 minutes

How compilers transform source code into executables

Compilers translate source code into a machine-readable format, either directly into object files or into platform-independent bytecode for a virtual machine.

#6about 5 minutes

The core stages of parsing source code

The parsing process involves multiple stages, including stream processing, tokenization, abstract syntax tree (AST) generation, and semantic analysis.

#7about 6 minutes

Structuring code with an Abstract Syntax Tree

An Abstract Syntax Tree (AST) represents code structure using nodes for statements and expressions, respecting operator precedence.

#8about 3 minutes

Traversing the AST using the Visitor Pattern

The Visitor design pattern provides a robust and type-safe way to traverse an Abstract Syntax Tree for analysis or code generation.

#9about 3 minutes

A live demo of a custom language REPL

A simple Read-Eval-Print Loop (REPL) demonstrates the custom language's features, including function definitions, currying, and AST inspection.

#10about 2 minutes

Implementing operator precedence with Pratt parsing

Pratt parsing is a technique that uses recursive function calls to elegantly handle operator precedence climbing in a compiler.

#11about 4 minutes

Understanding virtual machines and intermediate language

Process virtual machines execute platform-independent bytecode, or intermediate language (IL), which provides a linear instruction set derived from the AST.

Related jobs
Jobs that call for the skills explored in this talk.

Featured Partners

Related Articles

View all articles
BR
Benjamin Ruschin
What Developers Really Need to Create Great Code Demos
Every developer on earth has, at some point, had another developer to thank for a breakthrough, a success, an aha moment they wouldn’t have had without coming across that blog post, that open-source contribution, that reply on socials or that humble ...
What Developers Really Need to Create Great Code Demos
CH
Chris Heilmann
With AIs wide open - WeAreDevelopers at All Things Open 2025
Last week our VP of Developer Relations, Chris Heilmann, flew to Raleigh, North Carolina to present at All Things Open . An excellent event he had spoken at a few times in the past and this being the “Lucky 13” edition, he didn’t hesitate to come and...
With AIs wide open - WeAreDevelopers at All Things Open 2025
BB
Benedikt Bischof
How we Build The Software of Tomorrow
Welcome to this issue of the WeAreDevelopers Live Talk series. This article recaps an interesting talk by Thomas Dohmke who introduced us to the future of AI – coding.This is how Thomas describes himself:I am the CEO of GitHub and drive the company’s...
How we Build The Software of Tomorrow

From learning to earning

Jobs that call for the skills explored in this talk.

C# .NET Developer

C# .NET Developer

Rocken AG
Zürich, Switzerland

Remote
CHF95-115K
Unit Testing
Microsoft SQL Server