fixed resource trace declaration in grammar
implemented terminate conditions in simulation