Explore why someone would build a new interpreter, examine the aspects that influence the design of the runtime and of the programming language, and work through the steps to concretely implement the interpreter.
Key Features
Design a programming language to solve a particular problem, rather than a general-purpose one
Follow a bottom-up approach, from designing runtime to building a language-specific interpreter
Build an interpreter from scratch, focusing on achieving a minimally viable product
Book DescriptionDesigning a custom programming language can be the most effective way to solve certain types of problems-especially when precision, safety, or domain-specific expressiveness matters. This book guides you through the full process of creating your own language and interpreter, from design to implementation, using modern C++.
You'll start by exploring when and why building a language is worth it, and how to design one to match a specific problem domain. Along the way, you'll examine real-world interpreter architectures and how their design decisions affect language capabilities.
The book then walks through the entire process of building an interpreter: defining the syntax, building a parser and semantic model, designing an abstract syntax tree, generating executable instructions, and implementing a runtime. All examples are in modern C++, with a focus on clean architecture and real-world usability.
By the end, you'll have a fully working interpreter for a domain-specific language designed to handle network protocols-plus the knowledge and tools to design your own language from scratch. What you will learn
Gain hands-on experience building a programming language from scratch
Write an interpreter that can be embedded into existing environments
Reason about similarities and distinctions in programming languages
Understand the execution models of different languages
Identify the requirements for the runtime environment of an interpreter
Implement a lexer, parser, analyzer, and execution instruction emitter
Who this book is forThis book is tailored for intermediate to advanced software developers, particularly those interested in language design and implementation. It's ideal for programmers seeking to expand their skill set and tackle complex problems efficiently. Professionals working in roles such as software engineers, language designers, or system architects will benefit from the practical insights and hands-on experience provided in the book. Good understanding of C++ programming and basic understanding of language design concepts are recommended to fully grasp the content.
Sprache
Verlagsort
Maße
Höhe: 235 mm
Breite: 191 mm
ISBN-13
978-1-83763-807-9 (9781837638079)
Copyright in bibliographic data and cover images is held by Nielsen Book Services Limited or by the publishers or by their respective licensors: all rights reserved.
Schweitzer Klassifikation
Daniel Ruoso has more than 20 years of experience in software development. He has contributed to various projects over the years, specializing in Build Tooling, Static Analysis, Automated Code Refactoring. He was a contributor on the early development of the Raku programming language and of the Debian project. More recently, he contributed to the tooling study group of the ISO C++ working group. Daniel has also presented talks at LLVM Developer Meeting, C++Now and CppCon.
Table of Contents
Part 1: Setting up the Environment
The blurring lines between Native Code, Virtual Machines, and Interpreters
Instructions, Concurrency, Inputs, Outputs
Native types, user types, extension points
Putting it all together, making trade-off decisions
Review of Programming Language Paradigms
Values, Containers, and the Language Meta-model
Scopes, Namespace and Code Reuse
Putting it all together, creating a coherent vision
Initialization and Entry Point
Execution frames, the stack and the trampoline function
Running and Testing Language Operators
Lexing: Turning text into a stream of tokens
Parsing: Turning a stream of tokens into a parse tree
Analysing: Turning a parse tree into an Abstract Syntax Tree
Generating: Turning an Abstract Syntax Tree into Instructions
Proving that it works