import java.io.*;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Schema_Parse_Rules
{
	public static boolean process(String filename)
	{
		try
		{
		FileInputStream f=new FileInputStream(filename);
		FileOutputStream fo=new FileOutputStream("graph_final.txt",true);
		DataInputStream bf=new DataInputStream(f);
		
		PrintStream ds=new PrintStream(fo);
		
		while(bf.available()>0)
		{
			String str=bf.readLine();
			if(str.indexOf("FUNCTION")>0)
				return true;
			Pattern pattern = Pattern.compile("^*RULE");
			Matcher matcher = pattern.matcher(str);
					
			if(matcher.find())
			{
				if(!(str.indexOf("END_RULE")>0))
				{
					str=str.trim();
					int index=str.indexOf(' ');
					int for_index=str.indexOf("FOR");
				 ds.println(str.substring(index,for_index-1));
				}
			}
						
		}
		ds.close();
		
		
		}catch(Exception e)		
		{
			System.err.println(e);
		}
		return true;
	}
}