I'm working on a project where I'm converting from Fortran to Java. A lot of the changes are straight forward changes. However, in some cases, I have situations like this:
IF (___) GOTO number
will be changed to } while (___);
MOD(___,___)
will become ___ % ___
Where ___
represents characters of an unknown length.
How do I go about finding and replacing these strings?
Thanks!
Let me be more clear: the project must stand as it is. I realize there are tools that does this, and I realize that this isn't ideal. It is what it is unfortunately, so how would I go about doing what I'm asking?
You really probably need to do this via some kind of language-aware parsing of your Fortran code, rather than just by search-and-replace. You might be able to craft some regex that will cover all your cases, but it's always going to be nasty and error-prone.
I recommend looking at this project that provides Fortran parsing tools (in Java!) that will allow you to manipulate a Fortran abstract syntax tree and then code generate Java appropriately, if that is indeed what you are doing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.