Learn how to build something usable in the real word. A true programming language, with an efficient parser and a complete compiler. A language with its own editor. This is not about building toys.
There is no need to reinvent the wheel: we reuse open-source components and organize them together, to get something usable with a targeted effort.
Do you think it is not possible to build a parser, an interpreter, an editor and a simulator in less than 1.000 lines of code? Think again.
For those of you who have decided to build your own language or tool, and thus have the necessary impetus, I can recommend this as THE entry level guide to lexing, parsing and compiling with no prior experience required.
In this book we are going to see how to build languages and tools to support them.
For starters, it’s a challenge and that is motivation enough for some people. Maybe that’s why you are here. And if that is the reason, I promise it’s going to be a good challenge and you are going to have fun meeting it. But there are also other good reasons.
With the help of this book you will learn how to:
build a domain specific language (DSL), a language really good at doing something, like HTML or SQL
create a general purpose language (GPL), a language meant for anything, like C# or Ruby
create an esoteric programming language, a language designed to make a point, like Piet or Shakespeare
Creating a tool or a DSL can simplify your life as a programmer. And when your employer hears the magic words “increase productivity” it can even help in your job.
Creating an esoteric programming language can be a great way to put a new idea out there. To show that things can be done differently.
It is harder to succeed creating a GPL, but it can be done: Kotlin, Go, Ruby, Julia, Rust, etc. If you think about it, there have been many languages in the last few years. All of them have taken hold in some communities and made developers happier.
A Bit of Theory and Lots of Code
When I was learning to build languages I was disappointed: I could just find basic tutorials here and there, but what was missing was a complete course. One organized to lead me from the very beginning to the end. When there was something more deep, it was so abstract: a lot of compiler theory and not enough code.
I wanted a book with a clear plan and a pragmatic approach, but there wasn’t one.
So I learned building languages on my own. It took me years of professional experience in building languages to get there. Now I can share this knowledge, so that you can learn how to create your own language in a few weeks.
It’s still going to be a lot of work, but you will have help.
How This Book Will Help You
This book shows how we can reuse existing libraries and frameworks to create all the ecosystem necessary to support our languages.
The cost of building all the machinery to proper support a language used to be very high.
Today with a limited effort we can design a language and obtain:
a fast parser from a concise grammar definition
validation and model transformations with little code
generate JVM bytecode and get interoperability with other JVM languages or generate the language with the help of LLVM
obtain rich editors with syntax highlighting and autocompletion
We will see how to build all of this and more by defining small components in a smart way. The result will be something solid, complete and understandable.
About the Author
Federico Tomassetti is a Consultant Software Architect specialized in Language Engineering: I build languages, editors, parsers, compilers, interpreters and simulators.
I have an insane passion about Software Development: I love it since I was 8 years old and I keep thinking about it all the time. I have done several things: got my PhD in Software Engineering, done research and worked in Italy, Germany, Ireland and France. I spoke at meetups and scientific conferences, wrote papers and article, worked for TripAdvisor and Groupon.
Table of Contents
Part 0: Creating a Language
1. Motivation: why do you want to build language tools?
2. The general plan
3. The example languages we are going to build
Part I: the foundation
4. Writing a lexer
5. Writing a parser
6. Mapping: from the parse-tree to the Abstract Syntax Tree
7. Symbol resolution
Part II: compiling
10. Build an interpreter
11. Generate JVM bytecode
12. Generate an executable using the LLVM
Part III: editing support
13. Syntax highlighting
A 370-pages of pragmatic information.
100% Satisfaction Guaranteed If you are not happy, just ask for a refund.
Note About VAT
Not based in Europe? No need to worry about VAT, it does not concern you. Are you a European Company? You can get VAT back.
Not Ready to Buy the Book Yet? Start With the Free Email Course!