Many Fortran constructs such as variables, functions, subroutines have a name. It is coded by a node of variant "name".
Example 47:Insert a PRINT statement before a scalar assignment.
SCRIPT addprint () stat := $cstat // Test an assignment ok := FALSE IF (stat.VARIANT == "ass") THEN dest:=stat.LHS // Test if there is a "name" node // associated to the destination // expression (allways ?) . IF (dest.IDENT) THEN name_as_symbol := dest.SYMBOL name_as_fstring := dest.SNAME name_as_var := COPY(dest.IDENT) // Check that the variable is declared // as a scalar IF (name_as_symbol.DIMENSION==0) THEN cmd1 := " print *,'The variable',%e,'is assigned'" newstat1 := PARSESTAT(cmd1,name_as_fstring) cmd2 := " print *,'It old value was ',%e" newstat2 := PARSESTAT(cmd2,name_as_var) PASTE("BEFORE",newstat1,stat) PASTE("BEFORE",newstat2,stat) ok:=TRUE ENDIF ENDIF ENDIF IF (! ok) THEN ERROR(1,"Please, select an assignment 'scalar:=expression'") ENDIF ENDSCRIPT