// file: prompter.java // author: Robert Keller // // purpose: Modification of echoSexp showing how to do a prompt // // action: Repeatedly prompts single S expressions and prints them. // // run: java -cs prompter import Poly.*; // cs 60 package import java.io.*; class prompter { static String promptString = " > "; // 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; // Object to be read while( (ob = prompt(in, out)) != Tokenizer.eof ) // read next S exp { out.println(ob); // echo the value } 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 } }