Code Generators

Mike Lichak <>
22 Aug 1998 23:30:14 -0400

          From comp.compilers

Related articles
Code Generators (Kenn Heinrich) (1991-04-12)
Code Generators (Mike Lichak) (1998-08-22)
Re: Code Generators (Chris F Clark) (1998-08-24)
Re: Code Generators (1998-08-24)
Re: Code Generators (Joachim Durchholz) (1998-08-25)
Re: Code Generators (1998-08-25)
Re: Code Generators (1998-08-25)
| List of all articles for this month |

From: Mike Lichak <>
Newsgroups: comp.compilers
Date: 22 Aug 1998 23:30:14 -0400
Organization: Compilers Central
Keywords: tools, practice

Here's the input file for an report generator I wrote several years ago.
Forgive the length John. It the shortest one I could find.

REP( ;
                QUERY("Vendor" ,"ABINVDEP","IDVENDOR","lcVENDOR"),;
                QUERY("Bin" ,"ABINVDEP","IDLOC","lcSTART","lcEND"), ;
                QUERY("Cls" ,"ABINVENT","IVCLS","lcCLS"),;
                SUBHEADING( ;
                                DBFLD("VENDOR: " ,"ABINVDEP","IDVENDOR"),;
                                DBFLD(":" ,"ABVENDOR","VNAME"),;
                                DBFLD("Contact: " ,"ABVENDOR","VCO"),;
                                DBFLD(":" ,"ABVENDOR","VPH");
                              ), ;
                COLUMNS( ;
                                DBFLD("Part Number" ,"ABINVENT","IVNO",'C',10),;
                                DBFLD("Description" ,"ABINVENT","IVDS",'C',35),;
                                DBFLD("Cls" ,"ABINVENT","IVCLS"),;
                                DBFLD("Vendor Part
                                DBFLD("Last Order Date" ,"ABINVDEP","IDODAY"), ;
                                DBFLD("Last Order Cost" ,"ABINVDEP","IDLCOST") ;
              t( .F.,"ABINVENT",.F.,.F.,.F.,.F.,;
                t( .T.,"ABINVDEP",.F.,.F.,"ABINVENT->IVNO","ABINVDEP", ;



It's one big function call to the code generator. It generates about
1200 lines of well commented xBASE code. Not too pretty, but it sure
beats having to ever line-up headings ever again. The nested t()
functions do the navigation (is that the right word?) through the
indexed .DBF files.

It generates a bunch of standard functions, ie: opening files,
presents a consistent user interface, sticks in all sorts of error
checking I would never do if hand-coding (especially on Friday
afternoon), and allows me to tweek the database navigation path for
the best performance.

I have written several of these type of code generators the last 15
years, and they save a lot of time. And it's time to write something
similiar for a large Windows project.


Here's the problems I always run into. The code can be compiled and
delivered, as is, to the end-user, about 80% of the time. The rest of
the time, I have to hand-edit parts of the code.

Once I do that, and find a bug in my code-generator, or add a nifty
new feature to the code-generator, I have to hand modify or cut and
pasted that 20% of customized code.

The hand-edited parts are usually quite site-specific to fufill a
contract, and too intense to justify adding them to the
code-generator. Or all the hacks I've added make it too hard or
time-consuming to modify at all. Or the growth of the poorly designed
input syntax catches up to me. And it's nice to be backward compatible
with early projects that need mods and additions.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.