Hey All!

I made a code generator that works like this:

1) Read from a header file and produce an intermediate file (named File A) that has tags(inserted by me) that facilitates sorting out the information that is read from the header by me for:

-Function declaration

-Actual code for functions with arguments/params etc everything.

2) Read this intermediate file i.e File A and process the information for making another intermediate file (named File B) that I use for another purpose later on. :P File B uses File A and the result is an intermediate code file that has the following:

-Class Declaration

-Function Definitions i.e Actual code for functions with arguments/params etc everything (whatever is dictated by the requirements is output to this intermediate file B) along with some information that I need later, ;)

3) Read File B and use a config file named Input.config and use the information from the config file to alter the contents of the File B to produce the final processed file named File C(quite appropriate, isn¡¦t it? ;))

The input config file has stuff that I need to replace in File B for example Class Name etc.

What is the problem:

-Formatting is handled as desired by me in File B to get the results I¡¦m looking for and HERE IS THE PROBLEM:

1)What I need in File C is formatted code that wraps after 78 characters and the length of lines SHOULD NOT exceed 78 characters

2)Indented code inside if/for loops etc etc etc etc

For Example: File B

class Class_Name:public BaseClass { blah blah blah public: blah blah blah }

I CAN in File B control the formatting to some degree. ļ What I want is this in File C: File C

class ClassMyClassNameNoMatterHowLongItIsName:public BaseClass { blah blah blah public: blah blah blah }

MyClassNameNoMatterHowLongItIs is read from the config file and right now I use pattern matching and whenever I encounter Class_Name, I replace it with the information read from the input config file , Here in lies the problem, if I just use pattern matching and just *replace* the stuff , then , I have no control on the wrapping etc and in all likelihood, I lose most of the formatting information that I preserved in File B.

My questions are:

1) How and what do I do in order to preserve some sort of formatting in File C (my FINAL processed output file) after all the tags etc have been replaced?

2) Should I use a C++ program instead of a PERL script to generate the code in File C instead?

I must add here:

1) I¡¦m a C++ Programmer

2) I don¡¦t know PERL and all that I have managed to accomplish here has been rather painstakingly after debugging with print statements, so please reserve any comments on my illiteracy , I do know that I DON¡¦T know PERL.:p

3) I don¡¦t have nay other experience in PERL or scripting

Thanks in advance for your time and my apologies for the length of the post.

edited: Wed Oct 22 12:51:33 2003 by jeffa - readmore tag


In reply to Text Wrapping by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.