Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

aftermath

Code processor (not preprocessor, nompiler... POCESSOR!)

This topic is 5618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

sorry if this does not belong in this forum Hey everyone! I am going to keep this short because I am writing on my PPC. Does anyone know of a C/Cpp code processor that can automatically process large amounts of code that would be hard to do by hand. For example: • Append “_T(“ to the beginning and “)” to the end of any quotes string. • Automatically cast variables. Like if I have an integer transformation to a float, I want to cast it using “(FLOAT)” or “dynamic_cast(…)” • Ect… I hope you know what I mean. The examples above aren’t exactly what I want to do, so don’t tell me how to do them, just tell me if anyone knows of such a tool. Thanks. Tell me if I need to clarify my post.

Share this post


Link to post
Share on other sites
Advertisement
Why don''t you tell us exactally what you want to do so we can try to help you?

Karg

Share this post


Link to post
Share on other sites
There is a number of things that I need to do to my code.

Maybe someone knows of a source code formatter that can be changed programmatically or something like that.

There is no one thing that I want to do in particular… I just need it, ok?

Share this post


Link to post
Share on other sites
Well, you are pretty well going to have to write a program. You can use something like lex on unix, macros for an editor, a scripting language like Python or plain old C/C++. Whichever way you do it it is generally best to use several programs for a complex task rather than one huge complex one. You then write a script to run all of it. Do it in three phases. First extract the lines you want to change and the line number it was on. Then modify the extract file. Finally apply it back to the original. Also when you apply it back make sure the original line is still what it is suppose to be. Your most likely mistake after extracting the correct lines and making the correct changes is to apply it to the wrong file.

Doing it in phases and using seperate programs makes it easier to test and verify what you are about to do. Verifying that you got one in a hundred lines correctly identified and modified is a hassle and prone to error. Even successive lines with each having a differant modification made is prone to error. A file where every line is changed in the same manner makes the mistakes stand out. Simply applying the file at the end lets you stop in the middle and hand modify the odd error that would take a bunch of code to correct. A few minutes deleting a few lines or the next hour or two writing a hundred lines of code. The choice is yours.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
sed.

Share this post


Link to post
Share on other sites
C++ is in general pretty hard to parse - it is context dependant. Sadly. Have luck writing your own solution (unless you are lucky and it is pretty easy because it is a special case).


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites
Perl, that''s what it''s written for. Its not to hard to learn. We use it at work to do just what your talking about.

Cheers
Chris

Share this post


Link to post
Share on other sites
You could try M4.

Most C preprocessors are based on a cut down version of this beauty, so the syntax shouldnt scare you.

You can also get full source code for it.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
sed.


what the hEcK does that mean?

thanks to everyone else... i will try perl then :D

dynamic sigs are fresh!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!