private Grammar trim(Production[] prods)
	{
		myVariableMap=new HashMap <String, String>();
		char ch='A';
		for (int i=0; i<prods.length; i++)
		{
			String lhs=prods[i].getLHS();
			if (ch=='S' || ch=='T')
			{
				ch++;
			}
			int aa=lhs.indexOf("V(");
			while (aa>-1)
			{
			
		//		System.out.println("in 1st "+lhs+"===>    ");
				int bb=lhs.indexOf(")");
				String var="";
				if ((aa+bb+1) > lhs.length())
				{
					var=lhs.substring(aa, aa+bb);
					lhs=lhs.substring(0, aa)+ch;
				}
				else
				{
					var=lhs.substring(aa, aa+bb+1);
					lhs=lhs.substring(0, aa)+ch+lhs.substring(aa+bb);
				}
			//	System.out.println(var+ " and new lhs is = "+lhs);
				aa=lhs.indexOf("V(");
				
				myVariableMap.put(""+ch, var);
			//	System.out.println(var+" converted to : "+ch);
					
				//	lhs.replaceAll("V"+aa[j], "A");
				for (int k=0; k<prods.length; k++)
				{
					
					String inner_lhs=prods[k].getLHS();
					String inner_rhs=prods[k].getRHS();
					int a=inner_lhs.indexOf(var);
					if (a>-1)
					{
				//		System.out.println("in inner lhs  "+inner_lhs+"   ===>    ");
						inner_lhs=inner_lhs.substring(0, a)+""+ch+inner_lhs.substring(a+var.length());
				//		System.out.println(inner_lhs);
					}
					a=inner_rhs.indexOf(var);
					if (a>-1)
					{
			//			System.out.println("in inner rhs   "+inner_rhs+"   ===>    ");
						
						inner_rhs=inner_rhs.substring(0, a)+""+ch+inner_rhs.substring(a+var.length());
			//			System.out.println(inner_rhs);
						
					}
					prods[k]=new Production(inner_lhs, inner_rhs);
				}
				ch=(char) (ch+1);
		
			//	System.out.println(lhs);
			}
		}
		Grammar g=new UnrestrictedGrammar();
		g.addProductions(prods);
		return g;
	}