Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Text Wrapping
by tachyon (Chancellor) on Oct 22, 2003 at 04:25 UTC | |
by hehenoobhehe (Novice) on Oct 22, 2003 at 09:04 UTC | |
by tachyon (Chancellor) on Oct 22, 2003 at 09:52 UTC | |
by Anonymous Monk on Oct 23, 2003 at 07:24 UTC | |
by tachyon (Chancellor) on Oct 23, 2003 at 12:48 UTC | |
|
Re: Text Wrapping
by tachyon (Chancellor) on Oct 22, 2003 at 05:04 UTC | |
|
Re: Text Wrapping
by Anonymous Monk on Oct 22, 2003 at 03:43 UTC | |
by vek (Prior) on Oct 22, 2003 at 22:06 UTC |