TPC16 is a Turbo Pascal 7 command-line compiler implemented from scratch in Turbo Pascal, not Borland’s original source code. It aims to match Borland’s compiler both in the Pascal programs it accepts and in the Turbo Pascal unit and 16-bit x86 executable files it produces. Its developer presents it as a practical way to study compiler construction through a complete, working implementation: the code demonstrates scanning, parsing, symbol tables, scopes and units, expression processing, error reporting, inline assembly, intermediate code, register-limited code generation, optimization, and linking. Written in Turbo Pascal 7, it can compile itself in principle, though its size and DOS memory limits mean it must be built with the protected-mode BPC.EXE compiler rather than TPC.EXE.
The compiler is a DOS program that uses segment-and-offset addressing; it does not generate executable map files or debug information. A demo executable is available, and many parts of the source are published with explanations, but the complete source package is sold. The developer argues that examining its named data structures and algorithms can help readers build or extend their own compilers, although no detailed textbook is included. TPC32 is offered as a more flexible successor: it compiles with Delphi 7, replaces many 16-bit data-management constraints, supports long filenames, and still generates 16-bit x86 code. It also provides a starting point for Turbo51, a Pascal compiler for 8051 microcontrollers.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.