Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Building Programming Language Interpreters

You're reading from   Building Programming Language Interpreters A bottom-up approach to runtimes, execution, and implementation in C++

Arrow left icon
Product type Paperback
Published in Jan 2026
Publisher Packt
ISBN-13 9781837638079
Length 372 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Daniel Ruoso Daniel Ruoso
Author Profile Icon Daniel Ruoso
Daniel Ruoso
Arrow right icon
View More author details
Toc

Table of Contents (25) Chapters Close

Preface 1. Modeling the Programming Language Runtime Environment
2. Defining the Scope FREE CHAPTER 3. The Blurred Lines Between Native Code, Virtual Machines, and Interpreters 4. Instructions, Concurrency, Inputs, and Outputs 5. Native Types, User Types, and Extension Points 6. Putting It All Together: Making Trade-Off Decisions 7. Modeling the Programming Language Syntax
8. Review of Programming Language Paradigms 9. Values, Containers, and the Language Meta-Model 10. Lexical Scopes 11. Putting It All Together and Creating a Coherent Vision 12. Implementing the Interpreter Runtime
13. Initialization and Entry Point 14. Execution Frames, the Stack, and Continuations 15. Running and Testing Language Operators 16. Interpreting Source Code
17. Lexing: Turning Text into a Stream of Tokens 18. Parsing: Turning a Stream of Tokens into a Parse Tree 19. Analyzing: Turning a Parse Tree into an Abstract Syntax Tree 20. Generating: Turning an Abstract Syntax Tree into Instructions 21. Proving That It Works 22. Unlock Your Exclusive Benefits 23. Other Books You May Enjoy 24. Index

Making a function

The implementation currently just has the ability to transfer the control flow to a different operation tree. While it would be possible to represent a lot of different problems in this way, there are other capabilities that we normally associate with a function:

  • Executing a sequence of statements
  • Interrupting the control flow to leave the function immediately
  • Using variables and defining how their names are scoped

So far, every operation only executes once, and the shape of the execution is known by the static type of the argument tuple for the operator. Let’s look at the following example in Python:

print("Hello")
print("World!")

If we were to translate that into an operation tree, it would look something like this:

Figure 11.3: Operation tree for a sequence of statements

Figure 11.3: Operation tree for a sequence of statements

But if we tried to describe the “statement sequence” operator in the code as it is now, we would...

lock icon The rest of the chapter is locked
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Building Programming Language Interpreters
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon