Re: [dev] Preprocessor

From: Sijmen J. Mulder <ik_AT_sjmulder.nl>
Date: Thu, 2 May 2019 11:39:51 +0200

Hi Adrian,

Adrian Grigore <adrian.emil.grigore_AT_gmail.com> wrote:
> I built a preprocessor. It allows embedding shell code in any type of files.

A tool like this has been on my mind for a while but in a different
form: a more generic template-to-code tool that turns the literal parts
of a template into print statements:

 <body>
   <h1><% printf("Hello, %s!", "World!); %></h1>
   <p>Lorem ipsum dolor sit amet ...</p>
 </body>

becomes:

  ...
  int main() {
    puts("<body>[...]");
    printf("Hello, %s!", "World!);
    puts("</h1>[...]");
    return 0;
  }

It would need to know a bit about the target language.

For your shell example it could look like:

  <table>
  <% for p in "$1"/*; do %>
    <tr>
      <td><% echo "$p"; %></td>
    </tr>
  <% done %>
  </table>

I'm not sure of the best way to deal with the multi language aspect, to
have it built in or configurable in some way.

But mostly I'm sure it must have been done before better than I could.
Or that it's better done with a few lines of awk.

Sijmen
Received on Thu May 02 2019 - 11:39:51 CEST

This archive was generated by hypermail 2.3.0 : Thu May 02 2019 - 11:48:08 CEST