1

It happened I need to add (or change, or change order) a new function "FunctionB()" into an existing code base (php files, ie. text files) based on rule like the following: in the main section, ie. after the unique substring "MAIN CODE" ... find the second IF then else block and insert a new function "FunctionB(...)" block of code while original text is kept and would continue after the new insertion. - So not a simple search and replace and opposite extreme would be parsing of the code to tokens etc. - Now, I'm doing it in another programming language in my command, basically as a series of individiual processing steps while looping files and lines with some decision making logic. I'm not proficient enough in regular expressions compared to this "programming" technique, when I don't loose time experimenting with regex. I'm also able to evaluate, how much time and effort I will need to achieve required "text transformation".

My question: is there a tool to do it in more "clickable" way in order to define the rules ? Something analogic to "Query builder GUIs" for data? And I don't mean Informatica (= overkill), and I know awk/sed, of course. Some utility specializing exactly on defining text manipulation rules. I was considering to write it myself at least as a working tool, but that must have been solved already ?

3
  • What you want is a program transformation system. See en.wikipedia.org/wiki/Program_transformation Commented Feb 4, 2024 at 3:00
  • @Ira Baxter - thanks for pointing me to this type of SW. I didn't know about these. At the moment, I'll stay with my vbs scripting as the cheapest approach for my purpose. I was thinking about some specifically trained AI tool to be a better way. I'm investigating how to apply a certain change pattern to 200 files. I assume I need to get a local AI model and try this approach. Commented Feb 9, 2024 at 1:50
  • Not what I would suggest. If you can "train an AI" to sort of do this, you run the risk of it doing the changes incorrectly. Then you get to debug some significant fraction of your 200 places; if you are willing to do that, you should just hand patch the 200 places directly. The point of a PTS is that you can state the change you want to make in an extremely accurate and reliable way. Commented Feb 9, 2024 at 15:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.