Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

What matija says about HTML::Template is true, in fact, any templating system will most likely fit the bill, personally, I like Petal, but that one has some Unicode bugs and XML quoting bugs, and requires your templates to be wellformed XML, which is most likely not what you want.

At the moment, I only see two special needs for templating, string interpolation and recursive macros.

For (intelligent) string interpolation, you will want to pass in any Perl scalar and have it automagically quoted correctly as a C string, in the same way that HTML::Template can automatically URL-encode or HTML-encode any scalar variable.

While the C macro preprocessor can also take some of the work, it might be useful for you to have recursive macro calls in your templating system, especially if you want to construct complex macros from smaller parts or move all OS logic out into separate templates instead of cluttering your output with huge nested blocks of #IFDEF.

I would start out with HTML::Template, code in the C-string-quoting function, and write the first generation templates in that. Then you will find out what additional functionality you need, and can move to the second incarnation.


In reply to Re: Re: Re: Templating system for generating C code? by Corion
in thread Templating system for generating C code? by toma

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2024-03-28 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found