added foreach loops in yacc and in traverse