| 1 4 package gnu.kawa.lispexpr; 5 import gnu.mapping.*; 6 import gnu.math.IntNum; 7 import gnu.text.Char; 8 import gnu.text.Lexer; 9 10 12 13 public class ReaderDispatchMacro extends ReaderMisc 14 { 15 Procedure procedure; 16 17 public ReaderDispatchMacro(Procedure procedure) 18 { 19 super(ReadTable.TERMINATING_MACRO); 20 this.procedure = procedure; 21 } 22 23 public Procedure getProcedure() 24 { 25 return procedure; 26 } 27 28 public Object read (Lexer in, int ch, int count) 29 throws java.io.IOException , gnu.text.SyntaxException 30 { 31 java.io.Reader reader = in.getPort(); 33 try 34 { 35 return procedure.apply3(reader, Char.make(ch), IntNum.make(count)); 36 } 37 catch (java.io.IOException ex) 38 { 39 throw ex; 40 } 41 catch (gnu.text.SyntaxException ex) 42 { 43 throw ex; 44 } 45 catch (Throwable ex) 46 { 47 in.fatal("reader macro '"+procedure+"' threw: "+ex); 48 return null; } 50 } 51 } 52 | Popular Tags |