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

Execution Frames, the Stack, and Continuations

In the previous chapter, I started the process of implementing the interpreter’s stack machine. However, that implementation is not yet capable of handling control flow operations, such as conditionals or functions. In this chapter, I will add those capabilities, as well as discuss how the interpreter needs to manage the execution across multiple continuations.

More specifically, this chapter will work through the following:

  • How an operation tree needs to be treated as a value in order to allow redirecting the execution
  • The way in which the interpreter dynamically chooses what to invoke
  • How a function is made by a sequence of operations, control flow, and variable scopes
  • How the interpreter handles the calling of a function
  • How to implement an end-to-end example of a function declaration and its invocation

By the end of this chapter, you will have a practical understanding of how...

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