This set of functions allows the user to modify the fortran program. We emphasize the cut & paste concept in order to facilitate the user's operation:
Example 38:The following program applies the transformation described in the example 39
SCRIPT test() if_stat := $cstat IF (if_stat.VARIANT!="struct_if") THEN ERROR(1,"Please, select a IF-THEN statement") ENDIF PASTE("BEFORE",PARSESTAT(" print *,'before'"),if_stat) PASTE(1,PARSESTAT(" print *,'start'"),if_stat.THENCLAUSE) PASTE(0,PARSESTAT(" print *,'end'"),if_stat.THENCLAUSE) PASTE("AFTER",PARSESTAT(" print *,'after'"),if_stat) ENDSCRIPT
Example 39:a simple Fortran transformation
IF (X.EQ.10) THEN Y=X*2 CALL FOO(X,4) ENDIF
PRINT *,'before' IF (X.EQ.10) THEN PRINT *,'start' Y=X*2 CALL FOO(X,4) PRINT *,'end' ENDIF PRINT *,'after'
Example 40: Rename the index of a the DO statement given in argument.
SCRIPT main (dostat) // Get the old index oldindex := COPY(dostat.INDEX) // The new index is "ind" newindex := PARSEEXPR("ind") REPLACEIN(dostat,newindex,oldindex) ENDSCRIPT