NAME ^

pir.l - implementation of the lexical analyzer of the PIR assembly language.

DESCRIPTION ^

This file implements the lexical analyzer of the PIR assembly language.

The current approach is to create a three-pass compiler, but if any optimizations in this schedule can be made, then this is preferred. This needs more experimentation.

The first pass is the heredoc pre-processor, which converts all heredoc strings into normal strings (they are "flattened). Furthermore, this phase strips all comments, both POD and line comments.

The second pass is the macro pre-processor, which handles the .macro, .macro_const and .include directives. The resulting output is the file that can be fed into the actual PIR parser.

The third pass is then the PIR parsing phase. It takes the output of the macro pre-processor, which contains no heredoc strings and macros. For that reason, the PIR lexer is very simple and straightforward.

Each of the phases can be easily implemented. When they must be combined, the complexity grows quickly. Therefore, this approach, which is probably not the most efficient, is easier to maintain, and preferable.


parrot