Pattern 16Symbol Table for Monolithic Scope


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.


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.



Start of file

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

Get Language Implementation Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.