ReadTableEntry.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2001 Per M.A. Bothner
  2. // This is free software; for terms and warranty disclaimer see ./COPYING.
  3. package gnu.kawa.lispexpr;
  4. import gnu.text.Lexer;
  5. import gnu.text.SyntaxException;
  6. public abstract class ReadTableEntry
  7. {
  8. public static final ReadTableEntry illegal
  9. = new ReaderMisc(ReadTable.ILLEGAL);
  10. public static final ReadTableEntry whitespace
  11. = new ReaderMisc(ReadTable.WHITESPACE);
  12. public static final ReadTableEntry singleEscape
  13. = new ReaderConstituent(ReadTable.SINGLE_ESCAPE);
  14. public static final ReadTableEntry multipleEscape
  15. = new ReaderConstituent(ReadTable.MULTIPLE_ESCAPE);
  16. public static final ReadTableEntry constituent
  17. = new ReaderConstituent(ReadTable.CONSTITUENT);
  18. public static final ReadTableEntry brace // special handling for '{' and '}'
  19. = new ReaderConstituent(ReadTable.CONSTITUENT);
  20. /** Special handling of {@code '&'} for SRFI-108/109. */
  21. public static final ReadTableEntry ampersand
  22. = new ReaderExtendedLiteral();
  23. public static ReadTableEntry getIllegalInstance()
  24. { return illegal; }
  25. public static ReadTableEntry getWhitespaceInstance()
  26. { return whitespace; }
  27. public static ReadTableEntry getSingleEscapeInstance()
  28. { return singleEscape; }
  29. public static ReadTableEntry getMultipleEscapeInstance()
  30. { return multipleEscape; }
  31. public static ReadTableEntry getDigitInstance()
  32. { return constituent; }
  33. public static ReadTableEntry getConstituentInstance()
  34. { return constituent; }
  35. public int getKind()
  36. {
  37. return ReadTable.TERMINATING_MACRO;
  38. }
  39. protected Object read (Lexer in, int ch, int count)
  40. throws java.io.IOException, SyntaxException {
  41. throw new Error("invalid character");
  42. }
  43. public Object read (Lexer in, int ch, int count, int sharingIndex)
  44. throws java.io.IOException, SyntaxException {
  45. return ((LispReader) in).bindSharedObject(sharingIndex, read(in, ch, count));
  46. }
  47. }