Do you still remember Borland's Turbo Pascal? Pascal compiler most successful? If the answer is yes, then you probably remember that Turbo Pascal was made Turbo. A fast compiler generates executable code quickly enough. Featured integrated development environment (IDE) where you can edit, run and debug their programs. Originally created as the Blue Label Pascal by Anders Hejlsberg, has been licensed by Borland Turbo Pascal in the 1980's. The latest version of DOS was released in 1992 as Turbo Pascal 7.0. Borland has also published similar compiler for Windows and later, a new product, Delphi - The rapid development tool for Windows applications.
Have you ever wondered what makes a fast Turbo Pascal compiler? Well, if you're interested in Turbo Pascal procedure described here some basic units include the compiler. Turbo Pascal is unconventional design, as taught in the books of the compiler design. Its design is based on speed. Parser is closely associated with the code generator. There is a low-level intermediate code, but most of the raw code generated by the parser.
A good example of algorithms and data structures used in Turbo Pascal is TPC16. TPC16 is compatible with Turbo Pascal. It produces the drive and program files compatible with Turbo Pascal 7.0 compiler from the command line. TPC16 is written in Turbo Pascal. It was a lot of units in all.
Common features
Here said that all the global variables used by the compiler. Statements are divided into sections. Some sections declare variables to store the data for the specific module, developed and these variables are saved (pushed) in the treatment devices used.
Reserved Words
This device indicates the symbol table space, all reserved words. It is distinguished from other units, because the file also contains the hash values of reserved words, under a separate program.
Type Definitions
This unit defines the data structures that define the basic types of Pascal (integers, floats, extended Boolean, char, string, file, game, table, objects, etc.) The unit also includes support for type testing functions, table storage type of symbol and standard treatment.
I / O Utilities
Routines for reading and writing files are located in the device I / O Utilities. This device also contains procedures for handling errors and mistakes.
Symbol Table Management
symbol table management is one of the most important of all the internal compiler. This unit contains procedures to create a symbol table, symbol table to add the tags, look for the symbol table on the tag, the research unit, process or ability to store, especially in the identification, and all other acts their symbol tables.
Scanner
Here is positioned procedures, which scans the source file and generate a stream of tokens. Token is the smallest part of the source, processed by the analyzer. Scans treats the source files, skip comments, compiler directives, the processes and generate tokens.
Parser
The brain of the compiler. He reads the chips, controls language syntax and generates intermediate code. One reason for the rapid development resides in the analyzer. As code is generated that is close to executable code, the next steps in the compilation are fast enough.
Reviews
This unit handles the Pascal statements (for, while the second, while, etc.), short blocks and blocks all the time.
System Features
This function unit processes such as ABS, arctan, chr, int, bizarre, BFS, etc. and generate code for them.
System procedures
This unit manages the system procedures, as for the exit, fillchar, writeln, Inc., Val etc., and generates the code for them.
Expressions
This is the largest unit and contains functions and procedures to the terms of the process. The expression is something that should be calculated - from simple to handle multiple complex expression in parentheses. There are many cases that should be tested and treated. Procedures in this unit also generate most of the code.
Calculator
This unit contains procedures for handling various calculations. The calculation is a transaction with one or two expressions (addition, subtraction, multiplication, etc)
Building
This is the assembly line that processes a block of instruction in asm-end.
Build Types
This device shows the data structures necessary for inline assembler.
Code generator
This unit processes the intermediate code and generates executable code and linker necessary reference data. code generator also performs code optimizations.
OMF import
This unit import OMF OMF object files and records processes.
Linker
This unit generates the final executable code and creates the output files. Before code is generated for each reference point is recursively treated and marked. unmarked elements are not implemented and therefore not included in the final executable code.
There are many excellent books on the design and implementation of the compiler. However, the best book on the design of the compiler is the compiler. If you are interested in Turbo Pascal house or just need a source code compiler, which must examine the source code compiler Turbo Pascal - Turbo Pascal compiler written in Turbo Pascal. This source code shows the beauty of the Pascal programming language and reveals all the tricks needed to build a fast and compact compiler for all languages, not only Pascal.