Validating Program Symbol Usage
To build an interpreter, compiler, or translator for a programming language such as Cymbol, we’d need to verify that Cymbol programs used symbols (identifiers) properly. In this section, we’re going to build a Cymbol validator that checks the following conditions:
-
Variable references have corresponding definitions that are visible to them (in scope).
-
Function references have corresponding definitions (functions can appear in any order).
-
Variables are not used as functions.
-
Functions are not used as variables.
To check all these conditions, we have a bit of work to do, so this example is going to take a little bit longer than the others to absorb. But, our reward will be a great base from which to build ...
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.
Read now
Unlock full access