alpag.net manual
Introduction / Lexer / Lexer algorithm
< Lexical analysis process | Parser >

Lexer algorithm

Multiple methods for processing regular expressions exist, having different capabilities and time/space requirements. Method used by Alpag is known as DFA (Deterministic Finite Automaton). Regular expression patterns defined by user are transformed into single deterministic finite automaton which is embedded in generated lexer. Analysis is performed by reading subsequent input characters and using them to walk the automaton.

The DFA algorithm has several advantages of which most important are:

It also has some drawbacks:

DFA algorithm, with its speed and stability, seems to be optimal choice for lexers that are pre-calculated and permanently linked into target application.

The type of DFA implementation used by Alpag is known as table driven.

Major limitation of DFA method is potential large size of tables describing automaton. Alpag uses some simple yet effective methods for compressing DFA tables.

< Lexical analysis process | Parser >
Alpag Manual