Skip to Main Content
Language Implementation Patterns
book

Language Implementation Patterns

by Terence Parr
December 2009
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 2m
English
Pragmatic Bookshelf
Content preview from Language Implementation Patterns
Pattern 25Tree-Based Interpreter

Purpose

This pattern executes programs by constructing an AST from the source code and walking the tree.

This tree-based interpreter pattern builds a complete scope tree before executing a program. That means it can support both statically typed languages like Java and dynamically typed languages like Python. (It can resolve all symbols statically before execution.)

Discussion

The previous pattern directly executed source code, without processing it in any way. At the opposite extreme, a compiler translates source code to machine code, which we can then run natively on the processor. Per the compiler application pipeline from Chapter 1, Language Applications Cracked Open, a compiler builds an intermediate representation ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Implementation Patterns

Implementation Patterns

Kent Beck

Publisher Resources

ISBN: 9781680500097Errata Page