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

Building Scope Trees for Classes

Classes are like structs in that they can inherit members from another class (the superclass). That means classes have two parent scopes: the usual enclosing scope (physical location) and a superclass scope. To resolve symbols, sometimes we’ll chase the enclosing scope pointer, and sometimes we’ll chase the superclass pointer. Let’s start by looking at the scope tree for the following Cymbol code (see Figure 17, Scope tree for classes A and B).

images/symtab/class-symtab.png
Figure 16. Scope tree for classes A and B
symtab/class/AB.cymbol
​ 
// start of global scope //
​ 
class A {
 
public:
 
int​ x;
​ 
void​ foo()
​ 
{ ; }
 
}; ...
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