1 2 23 24 25 26 27 28 29 30 public class ASTReadStatement extends SimpleNode { 31 String name; 32 33 ASTReadStatement(int id) { 34 super(id); 35 } 36 37 38 public void interpret() 39 { 40 Object o; 41 byte[] b = new byte[64]; 42 int i; 43 44 if ((o = symtab.get(name)) == null) 45 System.err.println("Undefined variable : " + name); 46 47 if (o instanceof Boolean ) 48 { 49 System.out.print("Enter a value for \'" + name + "\' (boolean) : "); 50 System.out.flush(); 51 try 52 { 53 i = System.in.read(b); 54 symtab.put(name, new Boolean ((new String (b, 0, 0, i - 1)).trim())); 55 } catch(Exception e) { System.exit(1); } 56 } 57 else if (o instanceof Integer ) 58 { 59 System.out.print("Enter a value for \'" + name + "\' (int) : "); 60 System.out.flush(); 61 try 62 { 63 i = System.in.read(b); 64 symtab.put(name, new Integer ((new String (b, 0, 0, i - 1)).trim())); 65 } catch(Exception e) { 66 System.out.println("Exceptio : " + e.getClass().getName()); 67 System.exit(1); 68 } 69 } 70 } 71 } 72 | Popular Tags |