Pattern 16 | Symbol 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 ... |
Get Language Implementation Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.