|Code Generators firstname.lastname@example.org (Kenn Heinrich) (1991-04-12)|
|Code Generators email@example.com (Mike Lichak) (1998-08-22)|
|Re: Code Generators firstname.lastname@example.org (Chris F Clark) (1998-08-24)|
|Re: Code Generators email@example.com (1998-08-24)|
|Re: Code Generators firstname.lastname@example.org (Joachim Durchholz) (1998-08-25)|
|Re: Code Generators email@example.com (1998-08-25)|
|Re: Code Generators firstname.lastname@example.org (1998-08-25)|
|From:||email@example.com (Gene Wirchenko)|
|Date:||24 Aug 1998 13:34:22 -0400|
Mike Lichak <firstname.lastname@example.org> wrote:
>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.
I wrote a tiny compiler for generating much of the general code
that I need in my Visual FoxPro 5 forms. Maybe you can steal an idea
or two from me.
There are two files: a .sgi (Say Get Input (since my form class
implements the basics of @-say-get)) and the .prg.
Pass one of the compiler deals with validating the .sgi file. I
have constrained the language so it can be dealt with in one pass.
The .sgi file is basically a table with each control's parameters
are on one line. The are also comment lines and some modifier
commands. These are such things as that input is compulsory for the
previous control and that a #defined constant is required for the
previous control so the program can refer to the control regardless of
how the .sgi may be modified.
Pass two of the compiler merges the generated code into the .prg.
To do this, I defined merge directives. Each directive is a VFP
comment so VFP won't complain about it. It is followed by the
generated code and then by an end directive. When a merge directive
is encountered, the compiler reads to an end directive and then writes
out the directive, the new code, and the end directive.
There is additional checking for missing end directives.
The compiler is totally ignorant of any other code and simply
passes it through uninterpreted.
To create a form, I usually take an existing .sgi and .prg and
make my changes. The compiler will generate the appropriate code from
the .sgi and there it is.
Return to the
Search the comp.compilers archives again.