Next: , Previous: Preprocessor, Up: Internals

12.2 GPC's Lexical Analyzer

The source files gpc-lex.c and pascal-lex.l contain the so-called lexical analyzer of the GNU Pascal compiler. The latter file is processed with flex to produce pascal-lex.c which is not meant to be read by a human, but compiled.

This very first stage of the compiler is responsible for reading what you have written and dividing it into tokens, the “atoms” of a computer language. Here is, for example, where integer and real numbers such as 42 and 3.14e-5, string constants, symbols, keywords and identifiers etc. are recognized.

The main entry point is the function yylex which calls the flex-generated function lexscan which does the main work of token separation.