Stages in Using Gelex PreviousNext

This section lists the steps to follow to produce a working scanner using gelex. First, you have to write a description of the scanner you want to generate:

  1. Formally specify the scanner in a form recognized by gelex. For each pattern, describe the action that is to be taken when an instance of that pattern is recognized. The action is described by a sequence of Eiffel instructions.
  2. If the scanner is to be used as lexical analyzer associated with a parser generated by geyacc, you may want to inherit from the class containing the token type codes. This class is automatically generated by geyacc using the -t option.
  3. Redefine features such as reset or wrap if necessary.

To turn the above scanner specification into a runnable program, proceed as follows:

  1. Run gelex on the grammar to produce the scanner class.
  2. Add the following clusters to your ECF file depending on the Eiffel compiler you are using:
    where <compiler> is either ise or ge.
  3. Compile the Eiffel class generated by gelex, as well as any other classes in your system.
  4. In order to debug your scanner, the scanner skeleton class is equipped with Eiffel debug instructions with the key "GELEX". For example if you use ECF files, you just have to specify the following line in the option section:
        <debug name="GELEX" enabled="true"/>

    This will help you to find out what kind of tokens are recognized from input.

Note that contrary to false assumptions, there is no need to include in your system all libraries that come with Gobo Eiffel in order to take advantage of the facilities provided by gelex. During the design of the scanner skeleton, care has been taken to only use kernel classes such as ARRAY or STRING, and therefore avoiding the unnecessary overhead of other library classes. As a consequence, only the two libraries listed above are required: the scanner skeleton library and kernel adaptation library allowing portability across various Eiffel compilers.

Copyright 2001-2019, Eric Bezault
Last Updated: 25 September 2019