Regarding indentation using unix script

I have piece of Informatica code in a file as :

IIF(substr(flag,0,2)=1,false,IIF(flag= 1 ,0,NULL))

Please provide me with idea how to write a unix script which reads this file and write indented code into another file. The output in the second file should look as:

IIF(substr(flag,0,2)=1,
----false,
----IIF(flag= 1 ,
-------0,
-------NULL
-------)
---)

The same script should work for any number of IF loops and thus proper indentation should be taking place

------ denotes spaces

Thanks for the help in advance

You want to search for a "pretty print" or an "indent" utility. The former is more suitable for making (color) printouts, where as the indent utility is more useful for reformatting code according to some kind of coding standard. In UNIX, the GNU "indent" reformats C/C++, but there are others out there that accept other languages.

The alternative is to write your own parser for this language. But it might be faster to manually indent the lines, depending on how many lines there are.