private static Map<NonTerminal,List<Production>> calcProductionsStartingWith(Grammar gr){
  final HashMap<NonTerminal,List<Production>> productionsStartingWith=new HashMap<NonTerminal,List<Production>>();
  for (  NonTerminal nonTerminal : gr.getNonTerminals()) {
    final List<Production> list=new LinkedList<Production>();
    for (    Production p : gr.getProductions()) {
      if (p.getLHS() == nonTerminal)       list.add(p);
    }
    productionsStartingWith.put(nonTerminal,Collections.unmodifiableList(list));
  }
  return productionsStartingWith;
}

private static Map < NonTerminal , List < Production > > calcProductionsStartingWith ( Grammar gr ) { final HashMap < NonTerminal , List < Production > > productionsStartingWith = new HashMap < NonTerminal , List < Production > > ( ) ; for ( NonTerminal nonTerminal : gr . getNonTerminals ( ) ) { final List < Production > list = new LinkedList < Production > ( ) ; for ( Production p : gr . getProductions ( ) ) { if ( p . getLHS ( ) == nonTerminal ) list . add ( p ) ; } productionsStartingWith . put ( nonTerminal , Collections . unmodifiableList ( list ) ) ; } return productionsStartingWith ; }
build map nonterminal ( 1 ) - > ( * ) productions ( starting with nonterminal )
