public void createFirst() {

		// Initialize first with empty set
		first = initFirst();
		Map<Symbol, Set<Symbol>> prevFirst = initFirst();
		Map<Symbol, Set<Symbol>> nextFirst = new HashMap<Symbol, Set<Symbol>>();

		boolean hasChanged = false;	
		
		do {
			nextFirst = initFirst();
			
			for (NonterminalSymbol A : grammar.getNonterminals()) {
				for (List<Symbol> prod : grammar.getProductions(A)) {
					Set<Symbol> tempSet = new HashSet<Symbol>();
					//tempSet.add(grammar.EPSILON);
					boolean emptyPervFirst = false;
					
					for(Symbol s : prod) {
						if(prevFirst.get(s).isEmpty()) {
							emptyPervFirst = true;
							break;
						}
						else {
							if (tempSet.isEmpty()) {
								tempSet.addAll(prevFirst.get(s));
							} else {
								tempSet = plus(tempSet,prevFirst.get(s));
							}
						}
					}
					nextFirst.get(A).addAll(prevFirst.get(A));
					if (!emptyPervFirst) {
						nextFirst.get(A).addAll(tempSet);
					}
				}				
			}
			
			hasChanged = false;
			for (Symbol s : prevFirst.keySet()) {
				if (prevFirst.get(s).size() != nextFirst.get(s).size()) {
					hasChanged = true;
				}
			}

			prevFirst = nextFirst;
		} while (hasChanged);
		first = nextFirst;
	}