Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A goal of the generated code was to minimize the tracking, allocation and freeing of memory for reasons of both performance and reliability. In essence any memory used by a lexer, parser or tree parser is automatically tracked and freed when the instance of it is released. There are therefore factory functions for tokens and so on such that they can be allocated in blocksĀ and parceled out as they are required. They are all then freed in one go, minimizing the risk of memory leaks. This has only one side effect, being that if you wish to preserve some structure generated by the lexer, parser or tree parser, then you must make a copy of it before freeign freeing those structures, and track it yourself after that. In practice, it is easy enough not to release the antlr generated components until you are finished with their results.

...