// file: analyzeSexp.java // author: Robert Keller // // purpose: Showing how single S expressions can be read, then analyzed // using package polya // // action: Repeatedly reads single S expressions and analyzes them // // run: javac analyzeSexp.java ; java analyzeSexp import polya.*; import java.io.*; class analyzeSexp { static String promptString = " analyze > "; // default prompt static int count = 1; // line counter public static void main(String arg[]) { Tokenizer in = new Tokenizer(System.in); // S exp tokenizer PrintStream out = System.out; Object ob; while( (ob = prompt(in, out)) != Tokenizer.eof ) // read next S exp { out.println(Polylist.analysis(ob)); // analyze } out.println(); // new line } static Object prompt(Tokenizer in, PrintStream out) // prompt method { out.print(count++ + promptString); // display prompt out.flush(); // & increment count return in.nextSexp(); // get input } }