manpagez: man pages & more
info flex
Home | html | info | man

File: flex.info,  Node: Development Steps,  Next: Translation Guidelines,  Prev: Getting Started,  Up: Retargeting Flex

A.5.3 Development Steps
-----------------------

To write support for a language, you'll want to do the following steps:

  1. Clone one of the existing skeletons.  If the language you are
     supporting is named FOO, you should create a file named
     'foo-flex.skl'.

  2. Modify 'skeleton.c' to ass the digested form of your skeleton to
     the 'backends' list.

  3. Add the name of your skeleton file to EXTRA_DIST.

  4. Add a production to 'src/Makefile.am' parallel to the one that
     produces 'cpp-skel.h'.  Your objective is to make a string list
     initializer from your skeleton file that can be linked with flex
     and is pointed at by the skel nember of your language back end.

  5. The interesting part: mutate your new back end and skeleton so they
     produce code in your desired target language.

  6. Add a test suite for your back end.  You should be able to clone
     one of the existing sets of test loads to get good coverage.  Note
     that is highly unlikely your back end will be accepted into the
     flex distribution without a test suite.  Fortunately, adapting the
     existing tests should not be difficult.  There is some guidance in
     the 'tests/README' file of the source distrbution.

   Syntactically C-like languages such as Go, Rust, and Java should be
easy targets.  Almost anything generally descended from Algol shouldn't
be much more difficult; this certainly includes the whole
Pascal/Modula/Oberon family.

   The C99 back end can be used for production, but it is really
intended as a launch point to be cloned by people writing support for
additional languages.  Accordingly, it omits support for some features
that can't be practically ported out of C in order to lower the
complexity of what needs to be translated to a new target language.
These features are: the Bison bridge, header generation, and loadable
tables.

© manpagez.com 2000-2026
Individual documents may contain additional copyright information.