/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lab_isa;

import java.io.*;
import java.text.*;
import java.util.*;

/**Almomen, Eman x 
 *
 * @author ealmomen.stu
 */
public class Main {
    public static String include[] = new String[1000]; // array for input
    public static int ct1=0;

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try{
            
            BufferedReader reader = new BufferedReader ( new FileReader("input2.txt"));
            
          
            while(true){
            String line = reader.readLine();
            if(line == null){
                break;
            }// if
            include [ct1] = line;
            System.out.println("include["+ct1+"]: "+ include [ct1] );
            ct1 = ct1 + 1;
            
            }//while 
            
            System.out.println("");
            System.out.println("");
            System.out.println("");
            System.out.println("");
            
            loader();
            
            
        }catch(FileNotFoundException fnfe)
        {System.err.println("File not found");}
        catch(IOException ioe)
        {System.err.println("Input output Exception");}
        catch(NullPointerException npe)
        {System.err.println("Null Pointer Exception");}//try
        
   
       
    }// main

    public static void loader(){
      //  System.out.println("Hello, it's a memory");
                interpreter();
        
        int i=0;
        int end1=0, end2=0;
        int tend=0;
        
        String vary[] = new String[1000]; // 1d array for fro variable
        int vct =0;
                
        for(i=0; i<ct1; i++){
            if(include[i].equals("END")){
                end1 = i;
                System.out.println("the line # of 1st END: " +end1);
                tend++;
                break;
                }//if
            
        }//for
        
        for(i=end1+1; i<ct1; i++){
            if(include[i].equals("END")){
                end2 = i;
                System.out.println("the line # of 2nd END: " +end2);
                tend++;
                break;
                }//if
            
        }//for
        
        
         // error checking -----------------------------------------
        
        // 1. checking the nr of END whether it is 2 or not 
        if(tend !=2){
        System.out.println("Error! Nr of END is not 2");
        }//if
        
        for(i=0; i<end1; i++){
            StringTokenizer line1 = new StringTokenizer (include[i]);
            while (line1.hasMoreTokens()){
                vary[vct] = line1.nextToken();
                System.out.println(vary[vct]);
                vct++;
            }//while
            
        }// for
                
    }// loader
    public static void interpreter(){
       // System.out.println("Hello, it's a cpu");
       
    }//interpreter
}// class Main
