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 16Symbol Table for Monolithic Scope

Purpose

This pattern builds a symbol table for a language with a single, flat scope.

This pattern is suitable for simple programming languages (without functions), configuration files, small graphics languages, and other small DSLs.

Discussion

The primary goal when building a symbol table is to construct a scope tree. In this case, the scope tree is pretty boring since it’s a single node (the global scope). The following table indicates how to build the single scope by responding to input constructs. We technically don’t need to push and pop scopes for this simple case, but we’ll do so for consistency with the other patterns.

Upon

Action(s)

Start of file

push a GlobalScope. def BuiltInType objects for any ...

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