On Mon, Oct 04, 2004 at 10:32:51PM -0400, Mitchell N Charity wrote:
>    > Obligatory perl comment - TIMTOWTDI, and sometimes, a good way,
>    > regards both clarity and speed, is having perl read a BNF and write a
>    > parser in prolog, which does the parsing, and writes an AST in perl,
>    > which is then eval()ed.  Really.
>    > _______________________________________________

> I think that about covers it.
> An example application is parsing _un_preprocessed C code - macros,
> #ifdef's, type/identifier ambiguities and all.

Along a similar vein, I frequently generate sh code from perl rather than
simply make 'system()/qx/``' calls from perl. Though there are several benefits to
this approach, the most compelling, for me, is the ability to embed 'undo'
statements in the generated code so the shell code can, given an 'undo'
invocation, rollback the previous run. In a sense, it allows me to impose
transaction semantics on batch processes. Of course, this only works if you
can be prevent or avoid external agents from modifying the system during or
between batch runs.

In general, I have found code and text generation to be a powerful technique
since one can apply abstraction, indirection. and other useful language
concepts to the task.

-Gyepi

_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to