final Environment savedNtEnv2 = ntEnv;
res.getGrammars().stream().map(res::getGrammar)
.flatMap(grm->grm.getElementsOfType(CopperElementType.PRODUCTION).stream().map(grm::getGrammarElement).<Production>map(el->(Production)el))
.<Pair<Production, List<NameBinding>>>map(prod->new Pair<Production, List<NameBinding>>(prod, CopperTSL.<Type,String,Optional<NameBinding>>
zip(prod.getRhs().stream().map(cer->savedNtEnv2.lookup(cer.getName().toString()).getType()), prod.getRhsVarNames().stream(),
(type, name) -> (name == null)?Optional.empty():Optional.of(new NameBindingImpl(name, type)))
.<NameBinding>flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty())
.collect(Collectors.<NameBinding>toList()))
).forEach(updateCode(toGen,ntEnv,methNum, res.getClassName()));