Forwarding this to the gcc list, since it seems to be more releavant
to the topic of this list. Sorry for the confusion.

Regards,
  Akos Vandra


---------- Forwarded message ----------
From: Akos Vandra <axo...@gmail.com>
Date: 16 April 2014 12:48
Subject: Using GCC to convert markup to C++
To: gcc-h...@gcc.gnu.org


Hi!

We are developing a C++ Web Framework, and we use ERB for the markup
of the views.
I would like to use the GCC tool collection to convert that ERB markup
to C++ code that would actually do the rendering, so the markup
interpretation would happen at compile time.

How is that possible? Can you give me some pointers on what part of
the documentation I should read up on?

Is a frontend capable to generate C++ code? Is that the way this
should be solved? Or should I take another route?
The reason for using GCC would be its (presumed) capability of parsing
a language grammar extracting the tokens, which can be easily
translated into code afterwards.

Thanks,
  Akos Vandra


P.S. Something like:

"
<%#include <time> >
Hello ERB World!
You are the <%= count %>. visitor!
The current time is <%= strftime(time()) %>.
"

into

"
  #include "abstractview.h"
  #include "context.h"

  class MyView : public AbstractView {
    virtual void render(Context ctx);
  }
"

"
#include "my_view.h"
#include <time>

void MyView::render(Context ctx) {
  std::string s;
  s.reserve(10000);
  s.append("Hello ERB World!\n You are the ");
  s.append(count);
  s.append(". visitor!\n The current time is: ");
  s.append(strftime(time());
  s.append(".");

  return s;
}
"

Reply via email to