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 18Symbol Table for Data Aggregates

Purpose

This pattern tracks symbols and builds a scope tree for data aggregates such as C’s structs.

Discussion

To manage struct scopes, we’ll build a scope tree and define symbols just like we did in Pattern 17, Symbol Table for Nested Scopes. The only difference lies in symbol resolution. Member access expressions like a.b can see fields inside a struct.

In Building Scope Trees for Structs, we examined the scope tree for some sample Cymbol struct definitions. The goal of this pattern is to describe the rules and mechanism for building that scope tree and filling the nodes (scopes) with symbols. To get started, we need a new kind of scope tree node called StructSymbol to represent structs. Here’s ...

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