class.h 1.6 KB

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