A Lexer.

Now that it’s debugged, here’s some source for a lexer, and associated testapp.

  • Matches literal tokens only at the moment, not regexps (which I leave as an exercise to the reader).
  • Has Ansi and Unicode and Ordinal (numeric versions).
  • Also has some nifty arbitrary size set handling code.
  • Is not optimised: Some of the list and transition handling is (relatively) slow compared to compiled lexers. Also an exercise for the reader.

Source code.


An alternate Streaming System.

Delphi has fairly good support for RTTI (reflection). Quite a few of my programs need to stream sets of classes to disk, and read those classes back. This library leverages the RTTI system to provide automatic streaming of classes and published properties, with an extensible API to perform custom streaming.

The source is here. No documentation I’m afraid, you will have to read code and think.

A multi-index container.

Delphi offers some fairly simple containers: list, queue, hash table, but does not have trees or tries.

I present here a multi-index container which maintains a doubly linked list, with multiple (sorted) indexes into it. The indexes are implemented as AVL trees. You can create custom indexes and perform high speed efficient sorting, searching and iteration.

Unlike the STL, no knowledge of templates is required.