For original grammar
String= pqsqsr
o/p = GAAAAT
If semantic rules are at the end:
o/p = TAAAAG
Start from the TOP to Bottom, when a semantic rule comes first time don't do anything, but the time when you visit it last time and won't visit again, execute it.