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

Calling a function

The convention on how a function is called is a fundamental part of any runtime, interpreted or not. The function needs to be able to receive the arguments and produce the result. In the C++ language, for instance, that is specified as part of the application binary interface (ABI) of the specific platform.

In this interpreter, I will keep things simple. The arguments to the function will be represented as a single value that packs a dynamic list of values, which will then be bound to the parameters of the function.

The calling convention for the FunctionCall operation will be that Callable is given as the first argument and DynamicList as the second. The argument names are going to be described in Callable, and the FunctionCall operation will bind those arguments into LexicalPad according to their position.

So, the first step is adding a new type to the Value variant, which I am calling DynamicList. This will be simply a vector of values. I will not...

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