import java.io.*;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Schema_Parse_Entities
{
	public static boolean process(String file_name)
	{
		try
		{
		FileInputStream f=new FileInputStream(file_name);
		FileOutputStream fo=new FileOutputStream("graph_final.txt",true);
		FileOutputStream fo1=new FileOutputStream("Schema_Parse_Entities.txt");
		DataInputStream bf=new DataInputStream(f);
		
		PrintStream ds=new PrintStream(fo);
		PrintStream ds2=new PrintStream(fo1);
		boolean entity=false;
		boolean end_entity=false;
		String str_tmp=" ";
		while(bf.available()>0)
		{
			String str=bf.readLine();
			if(str.indexOf("RULES")>0)
				return true;
			Pattern pattern = Pattern.compile("^*ENTITY");
			//Pattern pattern2 = Pattern.compile("^*END_ENTITY");
			Matcher matcher = pattern.matcher(str);
			//Matcher matcher2=pattern2.matcher(str);
			
			if(matcher.find())
			{
				entity=true;
				if(!(str.indexOf("END_ENTITY")>0))
				{
					str=str.trim();
					int index=str.indexOf(' ');
					if(str.indexOf(';')>0){
						ds.println(str.substring(index,str.indexOf(';')));
						ds2.println(str.substring(index));
					}
					else
					{
				 ds.println(str.substring(index));
				 ds2.println(str.substring(index));
					}
				}
			}
			/*
			if(matcher2.find())
			{
				entity=false;
				end_entity=false;
				//str_tmp=" ";
			}
			
			if(entity&!end_entity)
			{
				str_tmp=str_tmp+str;
				//System.out.println(str_tmp);
			}
			else
			{
				str_tmp=str_tmp.trim();
				int index=str_tmp.indexOf('=');
				
				if(index>0)
				{
					String h=str_tmp.substring(0,index);
					int index_space=h.indexOf(' ');
				ds.println(h.substring(index_space));
				}
				
		// ds.println(str_tmp);
				str_tmp=" ";
			}*/
			//System.out.println("I am here");
			
		}
		ds.close();
		ds2.close();
		
		
		}catch(Exception e)		
		{
			System.err.println(e);
		}
		return true;
	}
}