Using GCC to convert markup to C++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}
"




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux