class.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* $Header$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* U S E O F C H A R A C T E R C L A S S E S */
  7. /* As a starter, chars are divided into classes, according to which
  8. token they can be the start of.
  9. At present such a class number is supposed to fit in 4 bits.
  10. */
  11. #include "charoffset.h"
  12. #define class(ch) ((tkclass+CharOffset)[ch])
  13. /* Being the start of a token is, fortunately, a mutual exclusive
  14. property, so, as there are less than 16 classes they can be
  15. packed in 4 bits.
  16. */
  17. #define STSKIP 0 /* spaces and so on: skipped characters */
  18. #define STNL 1 /* newline character(s): update linenumber etc. */
  19. #define STGARB 2 /* garbage ascii character: not allowed */
  20. #define STSIMP 3 /* this character can occur as token */
  21. #define STCOMP 4 /* this one can start a compound token */
  22. #define STIDF 5 /* being the initial character of an identifier */
  23. #define STCHAR 6 /* the starter of a character constant */
  24. #define STSTR 7 /* the starter of a string */
  25. #define STNUM 8 /* the starter of a numeric constant */
  26. #define STEOI 9 /* End-Of-Information mark */
  27. /* But occurring inside a token is not, so we need 1 bit for each
  28. class.
  29. */
  30. #define _I_ 01
  31. #define _O_ 02
  32. #define _D_ 04
  33. #define _H_ 010
  34. #define in_idf(ch) ((tk2class+CharOffset)[ch] & _I_)
  35. #define is_oct(ch) ((tk2class+CharOffset)[ch] & _O_)
  36. #define is_dig(ch) ((tk2class+CharOffset)[ch] & _D_)
  37. #define is_hex(ch) ((tk2class+CharOffset)[ch] & _H_)
  38. extern char tkclass[], tk2class[];