O'Reilly logo

The Definitive ANTLR 4 Reference, 2nd Edition by Terence Parr

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required