import java.lang.*; import java.io.*; import niceIO.*; import java.util.*; public class pc { public File fi; public FileInputStream fis; public niceInputStream f; public static void main(String argv[]) { pc P = new pc(); } public pc() { char c; char EOF= ((char)(-1)); String word=""; int i=0; System.out.print("File name:"); String n= new String(les.ordBS()); fi = new File(n); try{ fis = new FileInputStream(fi); f= new niceInputStream(fis); c= f.tegnNB(); Stack st= new Stack(); Stack cnt= new Stack(); while (c != EOF) { if (c=='(') { word= f.ordBS(); st.push(new String("(")); cnt.push(new Integer(f.LineNo())); while (!st.isEmpty() && c != EOF) { c= f.tegnNB(); if (c=='(') {st.push(new String("("));cnt.push(new Integer(f.LineNo())); } else if (c==')') {st.pop(); cnt.pop();} } if (c == EOF && !st.isEmpty()) { System.out.print("Unmached '(' at line: "+cnt.peek()); cnt.pop(); while (!cnt.isEmpty()) { System.out.print(", "+cnt.peek()); cnt.pop();} System.out.print("\n"); } else { i= (i+1) % 2; if (i==1) System.out.print(word+" "); else System.out.println("-> "+word); } } else if (c==')') System.out.println("Opening ')' at line: "+f.LineNo()); c= f.tegnNB(); } } catch(FileNotFoundException e){System.out.println("No file `"+n+"'");} } }