Node: Lexical analyzer, Next: , Previous: Preprocessor, Up: Internals



GPC's Lexical Analyzer

The source files gpc-lex.c and pascal-lex.c contain the so-called lexical analyzer of the GNU Pascal compiler. The latter file was created using flex from pascal-lex.l. This very first stage of the compiler (after the preprocessor which is a separate executable) is responsible for reading what you have written and dividing it into tokens, the “atoms” of each computer language. The main entry point is the function, yylex which calls the flex-generated function lexscan which does the main work of token separation.

Here is, for example, where the real number 3.14 and the subrange of integers 3..14 are distinguished, and where strings constants, symbols etc. are recognized.