The gml4gtk program is using flex to generate C source lexer code with the mkpl script.

The flex software is now on github at https://github.com/westes/flex

The newest manual is here at https://westes.github.io/flex/manual/index.html#Top
or in this file at flex.html

For C++ there is also a flex compatible tool at https://github.com/Genivia/RE-flex

The generated source C code does not create issues using valgrind or gcc-11 software
which means that the C code is of excellent quality.

It is possible to use own skeleton with flex with more fine tuning.

Using the flex lexer with memory wrappers and these options like this:


/* own yyalloc */
void *yyalloc (size_t n)
{
  return(dp_calloc(1,n));
}

void yyfree (void *ptr)
{
  dp_free (ptr);
  return;
}

void *yyrealloc (void *ptr, size_t n)
{
  return (dp_realloc (ptr,n));
}

%}

/* use own yyalloc */
%option noyyalloc
%option noyyfree
%option noyyrealloc

    /* no yywrap() at end-of-file */
%option noyywrap

    /* do not push back chars in stream function() */
%option nounput

    /* no input() function */
%option noinput

    /* input does not come from a tty. */
%option never-interactive

    /* no yywrap() at end of file */
%option noyywrap

    /* 8-bits scanner */
%option 8bit

    /* use nameprefix for routines */
%option prefix="hl"

    /* add debug output */
%option debug

    /* use clib to read data */
%option noread


Flex does not generate graph data but maybe something is possible.

And flex can be used with own customized skeletons using the -S option like this:
flex -Smyflex.skl input.l

To create myflex.skl, go to the source src directory of flex lexer tool 2.6.4 with flex.skl file.

Then use this sed command to generate myflex.skl:

sed 's/m4_/m4postproc_/g; s/m4preproc_/m4_/g' flex.skl | m4 -P -DFLEX_MAJOR_VERSION=2 -DFLEX_MINOR_VERSION=6 -DFLEX_SUBMINOR_VERSION=4 | sed 's/m4postproc_/m4_/g' > myflex.skl

The myflex.skl can be edited with some care because it is a mix of C, C++ and m4 language.

The ready-to-use skeleton for flex-2.6.4 lexer is here as text file in flex-2.6.4.skl.txt


The ready-to-use skeleton for flex-2.5.37 lexer is here as text file in flex-2.5.37.skl.txt